jquery: ajax example

2015-03-22 2019-12-30 00:23:40 Javascript,jQuery,ajax,EN

this is a simple code example to remember how it works, to show how the structure looks like.

$.ajax({
    url: 'Controller.php',
    type: 'post',
    data: oFormData,
    contentType: false,
    processData: false,
    dataType: 'json',
    statusCode: {
        404: function() {
            console.log("404 page not found");
        }
    },
    success: function(oResponse, status, xhr){

        console.log('success oResponse', oResponse);
        console.log('success status', status);
        console.log('success xhr', xhr);
    },
    complete: function(xhr, status){

        console.log('complete xhr', xhr);
        console.log('complete status', status);
    },
    error: function(xhr, status, error){

        console.log('error xhr', xhr);
        console.log('error status', status);
        console.log('error error', error);
    }
}).done(function() {
    console.log('done', true);
});

This website uses Cookies to provide you with the best possible service. Please see our Privacy Policy for more information. Click the check box below to accept cookies. Then confirm with a click on "Save".