This is my php code
if(isset($_POST['submit'])){
$post_string=$_POST;
$enc_string=json_encode($post_string);
print("<script>encfunction('$enc_string');</script>");
}
this is my javascript code
<script>
function encfunction(data)
{
alert("data");
alert("hello");
alert("I am an alert box!");
}
</script>
I want to get the result in that function because i have to sent json response using ajax but it shows:Uncaught ReferenceError: encfunction is not defined
.
I referred following links but it doesn't give the desired result: Javascript Uncaught Reference error Function is not defined
Uncaught ReferenceError: function is not defined with onclick
Uncaught ReferenceError: function is not defined jQuery
Can any one help me.