1

This is the piece of jQuery that's not working for me :

$.ajax({
  crossDomain: true,
  type: "POST",
  url: "https://www.testdatasolutions.com/reportgw",

  data: "ACCOUNT=creditreport123&PASSWD=asdj97sdf&PASS=2&PROCESS=PCCREDIT&NAME=Robert+Ice&SSN=891-42-3221&ADDRESS=111+W+8th+St&CITY=Fantasy+Island&STATE=IL&ZIP=60750&BUREAU=TU&PRODUCT=CREDIT&DEFAULTOUTPUT=XML"
})

 .done(function( msg ) {
  alert( "Data Saved: " + msg );
});

The output error says:

XMLHttpRequest cannot load https://www.testdatasolutions.com/reportgw. Origin http://pmr.techforge.us is not allowed by Access-Control-Allow-Origin.

A similar topic can be found here, but it covers only the cases where output is in JSON.

So my question is, is it possible to handle cross domain ajax requests returning XML, or must I absolutely use JSONP?

Community
  • 1
  • 1
Tool
  • 12,126
  • 15
  • 70
  • 120
  • also, I tried making the request in your example and the server returns an "invalid account" page. Add a error handler to your ajax call to see whats really happening. – Juank Jan 28 '12 at 17:51
  • @Juank That's because you're not behind a proxy. – Tool Jan 28 '12 at 18:12

2 Answers2

1

It must be JSONP, XML is not allowed for cross-domain requests by default.

However, with a little server-side programing you could create a proxy and load the data through curl or similar on the server side within your own domain, and output it as XML. That way you can access an url within your own domain instead and you won't have to do a cross-domain request from the client, it is handled "behind the scenes".

Christofer Eliasson
  • 32,939
  • 7
  • 74
  • 103
0

You can try with http://enable-cors.org/. You can check the list of browsers that support CORS at http://en.wikipedia.org/wiki/Cross-Origin_Resource_Sharing#Browser_support.

naresh
  • 2,113
  • 20
  • 32