我想在xajax函数(Php)中创建一个javascript函数,并作为响应分配给它。
<?php
require_once("Resources/xajax/xajax_core/xajax.inc.php");
$xajax = new xajax();
function foo()
{
$response = new xajaxResponse();
// The code needed should be here...
// Here create the javascript sintax using php and put it on the web
// No problem creating the sintax but
->// how I put it on a new <script></script> ????
// Here call the javascript
$response->script('myJavascript');
return $response
}
$xajax->configure( 'javascript URI', 'Resources/xajax/');
$xajax->register(XAJAX_FUNCTION,"foo");
$xajax->processRequest();
?>
<html>.......
<button onclick="xajax_foo()"></button>
......</html>
不知道我是否清楚了,但简而言之,我想要的是,在运行xajax之前,没有javascript,然后有一个javascript,它正在运行。也许我应该使用两个xajax响应,一个用于将脚本放入web,另一个用于调用它……但现在我需要你的帮助。
耽误您时间,实在对不起。
发布于 2013-06-27 04:33:43
我用下面的方法解决了这个问题:
$response->call("javascriptfoo","param1","param2");
发布于 2016-08-01 17:28:25
我找到了一个解决方案:
在PHP中包含以下内容:
$response->call("javascriptfoo()","$param1","$param2"));
您需要在HTML中使用以下代码:
<script... >
function javascriptfoo(param1,param2) {
alert(param1);
alert(param2);
}
</script>
https://stackoverflow.com/questions/12588359
复制相似问题