English 中文(简体)
jchery.get JSON 调回未到达
原标题:jQuery.getJSON callback not being reached

我一天大部分时间都在纠缠这个问题,我被吓得一塌糊涂。

我有一个.NET Web Service 返回 JSON 的序列响应, 并试图将其转换为能够获取更多序列化数据的新响应。 这两种服务在处理请求的逻辑上看起来都是一样的。 两者都将内容Type 设置为应用程序/ json, 并写入流中 。

我使用jQuery 1. 7.1 在客户方面,我将GEJSON 和 URL 发送到工作端点。 Firebug 显示结果会回来, 充满数据, 并在 JSONLint 和其他人中验证 。 我设置了. ajaaxSetup () 来赶上错误事件, 我得到这个消息 :

textStatus: parsererror
Error Thrown: Error: jQuery17109478366139694514_1337880510219 was not called
jqXHR Response Text: undefined

(i 格式化了电文)

我所看到的JSON就是这些:

[
    {
        "sourceType": "KML",
        "dataUrl": "http://firefly.geog.umd.edu/kml/download.php?file=kml_global_modis-hotspots.kml",
        "id": "https://example.com/KmlFeeds::KMLFeeds::FIRMS::World",
        "title": "FIRMS - World",
        "description": "MODIS hotspot / fire and burned area",
        "originator": "NASA LANCE",
        "spatialDomain": null
    },
    {
        "sourceType": "KML",
        "dataUrl": "http://firefly.geog.umd.edu/kml/download.php?file=Alaska_24h.kml",
        "id": "https://example.com/KmlFeeds::KMLFeeds::FIRMS::Alaska",
        "title": "FIRMS - Alaska",
        "description": "MODIS hotspot / fire and burned area",
        "originator": "NASA LANCE",
        "spatialDomain": null
    },
...
]

(空间域有时有捆绑框坐标,在字符串中只有逗号分隔小数)

我的旧网络服务以不同标签的几把键返回相同。 使用新服务我永远无法找到将所有这些数据都放入网站的回调。 它肯定会回到我身边, 并且看起来是有效的, 不管我怎么看它 。

我想看看新服务有什么问题, 如果我把请求的 URL 转换回旧的 URL, 我的客户工作很好。 但是回应是作为有效的 JSON 回来的, 这样我无法理解它是如何在成功回调时 遇到问题的。 想法呢?

最佳回答

看起来JQuery正在期待一个JSONP 网络服务,但服务器调用JSONP回调并不正确。

张贴您的 GetJSON 电话。 另外, 您能否张贴页面域名, 呼叫 JSON 和 Web 服务( 如有必要, 请将其标出), 以便我们看它是否跨域 。

EDIT:看来它确实必须具有交叉性,因为同一服务器上的不同港口都https://stackoverflow.com/ questions/1077218/are-different-ports-on-the-same-server-server-server-server-cross-domain-aaax-wise”>。所以这意味着你想要使用JSONP。问题似乎是你的新服务没有正确为JSONP(很可能是为JSONP服务)服务。你应该看看新旧的配置的不同。

问题回答

暂无回答




相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签