luleksde
luleksde

Reputation: 97

Jquery AJAX type property

I was looking into couchdb for the first time and wannted to make an interface using jquery. When trying to send an AJAX call to the API service(it does different things depending on the method of the http request), so when I set a "type" property, it always does a GET request, no matter if its set to POST, PUT, DELETE or GET.

$.ajax({
    url: "http://localhost:5984/newDBNAME",
    dataType: "jsonp",
    type: 'PUT',

    success:function(data){
        alert(data.db_name);
    }

});

Upvotes: 0

Views: 498

Answers (2)

Brad M
Brad M

Reputation: 7898

jsonp requests will always be get. What is technically happening here is jQuery is creating a script tag with the src set to the url (with the success function linked to the callback function appended to the end of the url, which jQuery handles automatically behind the scenes).

Upvotes: 1

Musa
Musa

Reputation: 97672

This is because you set the dataType to jsonp, jsonp only supports GET.

Upvotes: 1

Related Questions