Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>With a HTTP POST, data is normally sent from form inputs with the <strong><a href="http://www.w3.org/TR/html4/interact/forms.html#adef-enctype" rel="nofollow">enctype</a></strong> set to <code>application/x-www-form-urlencoded</code> format. So with an AJAX POST, we would usually send data in this format also and not as a query string parameter, which is how data is usually sent with a HTTP GET request and how you are sending data above.</p> <p>if you change your code to</p> <pre><code> function do_likes(post_id) { $.ajax({ type: "POST", url:"http://www.p-art.co.il/facebook_test/action.php", data : { post_id : post_id } }); } </code></pre> <p>it should work as expected (I'm not familiar with PHP but I assume that the URL you're posting to expects data in <code>application/x-www-form-urlencoded</code> format). with <a href="http://api.jquery.com/jQuery.ajax/" rel="nofollow"><code>jQuery.ajax()</code></a>, if you set the data object to the key/value pairs that you want to send to the server, jQuery will take care of providing the correct <code>enctype</code> for you based on the HTTP request type you are using (you can override the <code>enctype</code> if necessary, but usually this is not required and the defaults will be what you need in the majority of cases).</p> <p>Also, you may want to set a callback function to be called after the AJAX post has successfully completed. To do this add a <code>success</code> property to the object passed to the <code>$.ajax()</code> call.</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