English 中文(简体)
XML cannot be the whole program
原标题:
  • 时间:2009-11-20 16:11:01
  •  标签:
  • jquery
  • jsonp

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.

问题回答

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.

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.





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签