Note that there are some explanatory texts on larger screens.

plurals
  1. POAJAX/PHP/Jquery Issue with callback
    text
    copied!<p>I can't seem to figure out why this won't work. I have stripped all elements out and have striped this done to a base example. can someone please tell me what I am doing wrong. When I click on the button on the html page I get my initial alert, but never get an alert from my call backs.</p> <p>Here is the code for my html file. test.html</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;script src="http://code.jquery.com/jquery-1.5.js"&gt;&lt;/script&gt; &lt;script language="javascript" type="text/javascript"&gt; $(document).ready(function() { $("#test").click(function() { alert("!st"); $.ajax({ type : 'POST', url : 'test_ajax.php', dataType : 'json', data: { email : 'Jeremy' }, success : function(data){ alert(data.msg); }, error : function(XMLHttpRequest, textStatus, errorThrown) { alert("error"); } }); return false; }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input name="test" id="test" type="button" value="Click Me"/&gt; &lt;div id="results"&gt; Hello &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Now for the php: test_ajax.php</p> <pre><code>&lt;?php if (empty($_POST['email'])) { $return['error'] = true; $return['msg'] = 'You did not enter you email.'; } else { $return['error'] = false; $return['msg'] = 'You\'ve entered: ' . $_POST['email'] . '.'; } echo json_encode($return); ?&gt; </code></pre> <p>Please any assistance would be much appreciated.</p> <p>Thanks Jeremy</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload