Reputation: 249
I am using jquery to make an $.ajax() call to a REST web service. Based on the documentation I found, I need to use jsonp as the datatype in order to make this cross domain call (an XML document is what is actually returned). When running my code, however, I receive the error "XML cannot be the whole program".
Does anyone know what this error means and how to fix it (if at all)? Google searches have not provided much information and the other stack overflow post on this subject was not helpful to me either.
If you have additional questions, please let me know.
Upvotes: 3
Views: 3528
Reputation: 19165
If you need to return XML over a connection that requires JSON, you will have to wrap your xml. So, for example, if your document looks like this:
<magic8ball>
<outcome_looks_doubtful/>
</magic8ball>
Then you will need to do something like this:
{"value": "<magic8ball>
</outcome_looks_doubtful/>
</magic8ball"}
Then you are passing around JSON, like your jsonp datatype requires. All you have to do is extract your xml, and you're off and running.
Upvotes: 1
Reputation: 245479
Looks to me like you included a *.js file in your web app that contains <script></script>
around the code...which is not needed. Those tags are making your code look like one big XML document to the parser.
Upvotes: 1