XML不能是整个程序 [英] XML cannot be the whole program

查看:63
本文介绍了XML不能是整个程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jquery对REST Web服务进行$ .ajax()调用。基于我发现的文档,我需要使用jsonp作为数据类型,以便进行跨域调用(XML文档实际上是返回的)。但是,在运行我的代码时,我收到错误XML不能是整个程序。

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".

有谁知道这个错误意味着什么以及如何解决它(如果在所有)? Google搜索没有提供太多信息,而另一个堆栈溢出帖子对我也没有帮助。

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.

推荐答案

如果需要通过需要JSON的连接返回XML,则必须包装xml。因此,例如,如果您的文档如下所示:

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"}

然后你传递JSON,就像你的jsonp数据类型需要的那样。你所要做的就是提取你的xml,然后你就开始运行了。

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.

这篇关于XML不能是整个程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆