如何让 Ajax.Net PageMethod 返回 JSON
我正在使用 AJAX.Net 调用 ASP.Net PageMethod,它返回 JSON 序列化 JSON 数据
{"d":"[{\"Fromaddress\":\"[email protected]\",\"Toaddress\":\"[email protected]\"},{\"Fromaddress\":\"[email protected]\",\"Toaddress\":\"[email protected]\"}]"}
响应标头将内容类型声明为
"Content-Type application/json; charset=utf-8"
但是,数据仅作为字符串提供,并且似乎不作为 JSON 数据提供来自 JavaScript。我需要做什么才能使用 javascript 返回的 JSON 数据?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尽管这可能存在安全风险。相反,您可能想使用 JSON 解析器,例如这个可用的形式 https://github.com/douglascrockford/JSON-js/blob/master/json2.js
然后你会得到如下符号:
参见 http://www.json.org/js.html 有关此特定解析器的更多信息...我相信还有其他解析器可供选择,并且它们的工作方式非常相似。
Although this can be a security risk. Instead you might want to use a JSON parser, such as this one available form https://github.com/douglascrockford/JSON-js/blob/master/json2.js
Then you get notation like:
See http://www.json.org/js.html for more info on this particular parser... I believe there are others to choose from, and that they work very similarly.