【发布时间】:2015-03-15 20:36:02
【问题描述】:
这是我的 php 代码
if(isset($_POST['submit'])){
$post_string=$_POST;
$enc_string=json_encode($post_string);
print("<script>encfunction('$enc_string');</script>");
}
这是我的 JavaScript 代码
<script>
function encfunction(data)
{
alert("data");
alert("hello");
alert("I am an alert box!");
}
</script>
我想在该函数中获得结果,因为我必须使用 ajax 发送 json 响应,但它显示:Uncaught ReferenceError: encfunction is not defined。
我参考了以下链接,但它没有给出预期的结果: Javascript Uncaught Reference error Function is not defined
Uncaught ReferenceError: function is not defined with onclick
Uncaught ReferenceError: function is not defined jQuery
谁能帮帮我。
【问题讨论】:
标签: javascript php jquery ajax