1

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

Ram Sharma
  • 51
  • 1
  • 6

1 Answers1

1

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

Community
  • 1
  • 1
MeTitus
  • 3,390
  • 2
  • 25
  • 49
  • Thanks for the response, I already tryied the the datatype jsonp (sorry not to mention the required data is there but browser throughing an SyntaxError: Unexpected identifier in chrome and SyntaxError: missing ; before statement in Mozila) and reson might be the return type of the request (it is text/html not jsonp or json), though i am going to make changes to my code as explained on the post on the link given by you, thanks – Ram Sharma Mar 29 '13 at 17:14
  • What technologies are you using? I remember I friend of mine who was having the same issue. He was using PHP, so what he did was, create a new PHP Util page to make a remote call, he then change his javascript to call that PHP page, something very easy that you can do. – MeTitus Mar 29 '13 at 17:57
  • yes this is easily possible with the PHP by creating a proxy (for remote call), but i am only dependent on ajax call and HTML pages and can't use PHP,asp or asp.net. – Ram Sharma Mar 29 '13 at 18:18
  • Then you have no way of doing it. – MeTitus Mar 29 '13 at 18:23
  • ok, thanks for your help, i will try a little bit (but i suppose i don't have any other option as explained by you) otherwise i will go with the proxy using PHP or asp :) – Ram Sharma Mar 29 '13 at 18:24