Curtis
Curtis

Reputation: 103348

jQuery.ajax POST request converted to GET

I have the following jQuery code:

    $.ajax({
        url: Url,
        dataType: 'JSONP',
        type: 'POST',
        success: function (data, textStatus, jqXHR) {
            //callback function here
        },
        error: function (xhr, ajaxOptions, thrownError) {
            //report error
        }
    });

However, when i view this AJAX request in Fiddler, my request has been converted from a POST to a GET.

This is not allowed with the API I'm connecting to, as it must be a POST request.

Why is this happening?

Upvotes: 2

Views: 1863

Answers (3)

LisaK1308
LisaK1308

Reputation: 181

You cannot use POST with JSONP see https://groups.google.com/forum/?fromgroups=#!topic/jquery-dev/5-tKI-7zQvs for more detail on this.

Upvotes: 1

Sushanth --
Sushanth --

Reputation: 55740

dataType: 'JSONP', 

is always a GET request

Upvotes: 1

SLaks
SLaks

Reputation: 887275

JSONP requests can only be GETs.

Remove dataType: 'JSONP'.

Upvotes: 8

Related Questions