How to use type: "POST" in jsonp ajax call

Manoj Singh picture Manoj Singh · Dec 22, 2010 · Viewed 109.3k times · Source

I am using JQuery ajax jsonp. I have got below JQuery Code:

 $.ajax({  
        type:"GET",        
        url: "Login.aspx",  // Send the login info to this page
        data: str, 
        dataType: "jsonp", 
        timeout: 200000,
        jsonp:"skywardDetails",
        success: function(result)
        { 
             // Show 'Submit' Button
            $('#loginButton').show();

            // Hide Gif Spinning Rotator
            $('#ajaxloading').hide();  
         } 

    });  

The above code is working fine, I just want to send the request as "POST" instead of "GET", Please suggest how can I achieve this.

Thanks

Answer

Nick Craver picture Nick Craver · Dec 22, 2010

You can't POST using JSONP...it simply doesn't work that way, it creates a <script> element to fetch data...which has to be a GET request. There's not much you can do besides posting to your own domain as a proxy which posts to the other...but user's not going to be able to do this directly and see a response though.