Ajax Error: Console says - POST is not defined

Phoenix picture Phoenix · Feb 18, 2014 · Viewed 8.8k times · Source

I have written the following jQuery code:

$('#Submitter').click(function(f) {

    x = $('#link').serialize();
    $('body').append(x);
    $.ajax({
        type:POST,
        url:"engine.php",
        data:x,
        success: function(i){
            console.log(i);
            $('#i').html(i);
        }
    });
});

Each time after clicking on the <input id="Submitter" type="button" value=Submit> element, Firefox's console displays the error: ReferenceError: POST is not defined.

Where is the issue and how to resolve this issue?

Thank you.

Answer

markcial picture markcial · Feb 18, 2014

replace your code like this :

$('#Submitter').click(function(f) {

    x = $('#link').serialize();
    $('body').append(x);
    $.ajax({
        type:'POST',
        url:"engine.php",
        data:x,
        success: function(i){
            console.log(i);
            $('#i').html(i);
        }
    });
});

POST needs to be enclosed with quotes