我用ajax脚本调用php文件。但是当我试图在调用的php文件中调用JavaScript时,它不会给我回复的JavaScript结果。它给了我 完整脚本存储在变量中。
的index.php
$.ajax({
type: "POST",
dataType: "json",
url: "response.php", //Relative or absolute path to response.php file
data: data,
success: function(data) {
//Here i am print response
}
});
response.php
$return = $_POST;
$return["js"] = "<script>test();</script>";
$return["json"] = json_encode($return);
echo json_encode($return);
?>
<script>
function test(){
return 'Hello';
}
任何人都可以建议我。提前致谢