News for hackers. Stuff that matters.
Re:Ask HN: When to learn AJAX? by revoltingx on Sunday October 24, 2010 @06:41PM (#1827564)
If you are learning jQuery, then doing AJAX with jQuery is extremely easy.

First, you have to learn how code a server side application that send JSON or XML encoded data.

Then you can load it with jquery using .ajax like so:

    $.ajax({url: 'yoururl.com/script',

        data: 'field1': 'myval',

        success: function(data)

        {

            //call to server worked, json/xml has been auto
           
            //inflated into the data object
        },

        error: function()

        {

            //the call failed, maybe a 404 or 500 error.

        });

That's it! You'll want to then manipulate your DOM accordingly, such as disabling any 'buttons' setting progress status, etc.

There are no comments on this comment yet.