Ram Sharma
Ram Sharma

Reputation: 51

Cross domain Ajax call from HTML page (can't use any proxy)

I was trying to get some information from another server using ajax post call as .

$.ajax({
                    type: 'POST',
                    url: testURL,
                    data: data,
                    //dataType: 'jsonp',
                    dataType: "script",                        
                    success: function (data) {
                        alert("Successfully posted (Test) : " + data);
                    },
                    error: function (ts) {
                        alert("Inside Error : " + ts.responseText);
                    }
                });

Here testURL is the URL where i am posting the data (Cross domain requests are only possible if datatype is either jsonp or script), and it suppose to return text/html data back (what fiddler says will be the return type for the data). I am not sure if i can use any proxy as pages are normal HTML pages. Isn't there any way to get the [data] as text (as for now success expecting JASONP data and alert("Successfully posted (Test) : " + data); only showing data as undefined). I can't make any changes to API or whatever it is on the remote Server. Thanks for the help in advance.

Regards

Upvotes: 1

Views: 381

Answers (1)

MeTitus
MeTitus

Reputation: 3428

Without a proxy you cannot do it. If that is in a windows box, you can create a COM object to make the call to that server and from your JavaScript you call that COM.

UPDATE:

Well it seems you can with JSONP

jsonp with jquery

Upvotes: 1

Related Questions