JavaScript: Using the Ajax jQuery API

From The Travis van der Font Wiki
Jump to: navigation, search
Perform an asynchronous and XML HTTP (Ajax) request:
$.ajax(
{
    url:    'submit.php',
    method: 'POST',
    data: {
        name: name.value,
        date: date.value,
        lang: lang.value
    },
    success: function (resultData)
    {
        result = JSON.parse(resultData);

        console.log(result);

    }).done(function(){}).fail(function (jqXHR, textStatus)
    {
        console.log('Request failed: ');
        console.log(textStatus);
    });
}
Functionality reference can be found at: api.jquery.com/jquery.ajax