Zend framework 运行使用Zend Framework ZendX ajaxLink函数时返回的javascript代码
我一小时前就开始工作了,但一定是改变了什么。 我应该如何使用ZendX调用ajaxLink,以便执行响应html中的任何javascript?我尝试了Zend framework 运行使用Zend Framework ZendX ajaxLink函数时返回的javascript代码,zend-framework,jquery,zendx,Zend Framework,Jquery,Zendx,我一小时前就开始工作了,但一定是改变了什么。 我应该如何使用ZendX调用ajaxLink,以便执行响应html中的任何javascript?我尝试了processData,因为我想我用过,但现在它不起作用了 <?php echo $this->ajaxLink('Click me and I will run the returned javascript code', $this->url(array('controller' =&g
processData
,因为我想我用过,但现在它不起作用了
<?php echo $this->ajaxLink('Click me and I will run the returned javascript code',
$this->url(array('controller' => 'foo', 'action' => 'bar')),
array('id' => 'myid'),
'processData' => true,
'method' => 'post',
'async' => false
),
array('a_posted_id' => $the_posted_id));?>
响应是如何返回的 一般在非zend中。您可以通过javascript构建javascript标记
var script = document.createElement('script');
script.type = 'text/javascript';
script.text = "the returned javascript";
document.getElementsByTagName('head')[0].appendChild(script);
这将自动运行代码
或者让Ajax将url返回到文件,并设置标记的src而不是文本
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = "/the/returned/link.js"
document.getElementsByTagName('head')[0].appendChild(script);
在这两种情况下,javascript都将自动运行
如果这没用,很抱歉 如何返回响应 一般在非zend中。您可以通过javascript构建javascript标记
var script = document.createElement('script');
script.type = 'text/javascript';
script.text = "the returned javascript";
document.getElementsByTagName('head')[0].appendChild(script);
这将自动运行代码
或者让Ajax将url返回到文件,并设置标记的src而不是文本
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = "/the/returned/link.js"
document.getElementsByTagName('head')[0].appendChild(script);
在这两种情况下,javascript都将自动运行
如果这没用,很抱歉 这应该可以工作,可能只是
ajaxLink()代码中的一个bug。我最终返回了JSON编码的数据,并使用javascript函数来处理返回的数据。这应该可以工作,可能只是ajaxLink()代码中的一个bug。我最终返回了JSON编码的数据,并使用javascript函数来处理返回的数据。没有人知道如何运行返回的javascript代码??:)没有人知道如何运行返回的javascript代码??:)