Jquery Ajax Requests

Jquery ajax requests are easier to perform as most of the legwork is already done for you.

You simply make the data you want to send in an object like this

var data_to_send = {"thetime":"18:30"};

this is represented as post data key/data pairs.

so “thetime” is the key and “18:30” is the data. Once you have the data you can start the actual request.

var data_to_send = {"thetime":"18:30"};

  url: "http://localhost/myfile.php", // the url you want to request
  data: data_to_send, // the data you want to send
  error: function() {
    // what you will do on a failed request
  success: function(data) {
    //what you want to do on success
  type: 'POST'

If you want to learn more you can go straight to http://api.jquery.com/jquery.ajax/ for more information and a larger example set.

Leave a Reply

Your email address will not be published. Required fields are marked *