JQuery Ajax is sending GET instead of POST

前端 未结 11 554
野性不改
野性不改 2020-12-03 00:20

The following code triggers a GET instead of a POST HTTP request.

function AddToDatabase() {
  this.url = \'./api/add\';
}

AddToDatabase.prototype.postData          


        
11条回答
  •  余生分开走
    2020-12-03 00:46

    For me, your piece of code look OK, but if you want to be sure, you can use $.post instead of $.ajax

    $.post('ajax/test.html', function(data) {
     $('.result').html(data);
    });
    

    jquery link : http://api.jquery.com/jQuery.post/

提交回复
热议问题