0

I use jQuery Ajax to send data to server. I set post type as POST but data always get send using GET method. How to send data using Post method?

$.ajax({
        type: "POST",        
        dataType: 'jsonp',            
        url: 'http://do.convertapi.com/Web2Image/json/',
        data: {
            'CUrl':$('#txtUrl').val(),
            'OutputFormat':'png',
            'PageWidth':600,
            'ApiKey':apiKey
        },
        jsonp: "callback",
        success: function (data) {               
        if (data.Result)
        {                
            $('#imgSnapShot').attr('src','data:image/png;base64,'+data.File); 
            $('#dvStatus').text("Converted successfully!");
        }
        else {
            $('#dvStatus').text("Error: " + data.Error);
        }             
        },
        });

As Graham Clark posted, jsonp Ajax requests are always posted as GET. If I remove jsonp option I get another problem, cross domain posting error. Is there any solution for my problem?

3 Answers 3

1

As it a 5 year old question but still if some one finds it useful .. More recently browsers have implemented a technology called Cross-Origin Resource Sharing (CORS), that allows Ajax requests to different domains. so have to use cors instead of jsonp

Sign up to request clarification or add additional context in comments.

Comments

0

You can't send cross-domain requests via JSONP - it doesn't use XMLHttpRequest. See here for more information:

http://groups.google.com/group/jquery-dev/browse_thread/thread/e7eb4a23eef342fb?pli=1

Comments

0

I believe jsonp is always sent with a GET request. If you need POST then use json. Check this question for details.

1 Comment

I use jsonp to overcome cross domain posting problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.