Php jquery append上的XML标记语法无效
你能帮我吗Php jquery append上的XML标记语法无效,php,jquery,Php,Jquery,你能帮我吗 class Custom_View_Helper_AddThis extends Zend_View_Helper_Abstract { static $instances = 0; /** * @var Zend_View_Interface */ public $view; /** * Return AddThis social sharin toolkit * @param $url uri o
class Custom_View_Helper_AddThis extends Zend_View_Helper_Abstract
{
static $instances = 0;
/**
* @var Zend_View_Interface
*/
public $view;
/**
* Return AddThis social sharin toolkit
* @param $url uri of page to share
* @param $title title of page
* @param $anews render social addthis at the end of the news
* @return void
*/
public function addThis($url = null, $title = null, $anews = false) {
$domain = 'http://' . $_SERVER['HTTP_HOST'] . '/';
$link = $domain . $url;
$html = <<<EOT
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style" addthis:url="$link" addthis:title="$title">
<a class="addthis_button_linkedin_counter"></a>
</div>
<!-- AddThis Button END -->
EOT;
$html2 = sprintf('
<div class="addthis_toolbox addthis_default_style" addthis:url="%s" addthis:title="%s">
<a class="vl addthis_button_google_plusone" g:plusone:size="tall"></a>
</div>', $link, $title);
$tracking = "
var addthis_config = {
data_ga_property: 'UA-XXXXXXXX-X',
data_ga_social: true
};" . PHP_EOL;
$src = "//s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f94ba586f83fcc8";
self::$instances += 1;
$mscript = $this->view->HeadScript();
if (self::$instances == 1) {
$mscript->appendScript($tracking);
if ($anews) {
$mscript->appendScript('
$(document).ready(function(){
$("#social_link").append('. $html2 .');
});
');
}
$mscript->appendFile($src);
}
return $html;
}
/**
* Sets the view field
* @param $view Zend_View_Interface
*/
public function setView(Zend_View_Interface $view) {
$this->view = $view;
}
}
class Custom\u View\u Helper\u add这扩展了Zend\u View\u Helper\u抽象
{
静态$instances=0;
/**
*@var Zend_视图_接口
*/
公众视野;
/**
*返回此社交共享工具包
*@param$url要共享的页面的uri
*@param$页面标题
*@param$anews在新闻结尾处呈现社交addthis
*@返回无效
*/
公共函数addThis($url=null,$title=null,$anews=false){
$domain='http://'。$_服务器['http_主机]./';
$link=$domain.$url;
$html=
EOT;
$html2=sprintf('
“,$link,$title);
$tracking=”
var addthis_config={
数据属性:“UA-XXXXXXXX-X”,
社会数据:真实
}“.PHP_EOL;
$src=“//s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f94ba586f83fcc8”;
self::$instances+=1;
$mscript=$this->view->HeadScript();
if(self::$instances==1){
$mscript->appendScript($tracking);
如果($anews){
$mscript->appendScript($mscript)
$(文档).ready(函数(){
$(“#社交链接”).append(“.$html2”);
});
');
}
$mscript->appendFile($src);
}
返回$html;
}
/**
*设置视图字段
*@param$view Zend_view_界面
*/
公共函数setView(Zend_View_接口$View){
$this->view=$view;
}
}
我想为zend项目创建一个视图助手,该项目将生成社交共享插件
我正确设置了第一个图标和链接,但是发送到jQuery函数的图标和链接不起作用,并且在firebug控制台中得到了无效的XML标记语法。我试了一次又一次,我所做的一切似乎都不管用
这里生成了javascript
$(document).ready(function(){
$("#social_link").html(
<div class="addthis_toolbox addthis_default_style" addthis:url="http://ayaou//news/bonjour-ayaou" addthis:title="Bonjour Ayaou">
<a class="vl addthis_button_tweet" tw:count="vertical"></a>
<a class="vl addthis_button_google_plusone" g:plusone:size="tall"></a>
<a class="addthis_button_facebook_like" fb:like:layout="button_count"
fb:like:action="recommend"></a>
<a class="addthis_button_facebook_send"></a>
</div>);
});
$(文档).ready(函数(){
$(“#社交链接”).html(
);
});
好的,我将代码更改为一个简单且重复的html代码。无效的xml在哪里?好的,我将从helper无效xml标记语法生成的代码粘贴到g:plusone…我认为g:plusone:size=“toll”
不是有效的html。你们试过使用兼容XHTML的AddThis脚本吗?并没有,我选择HTML5作为我的脚本layout@MarcelDjaman我的名字在你的URL中做什么3.