Using CLASSIC ASP to return data to jsonp call

懵懂的女人 提交于 2019-12-12 15:48:41

问题


I have been through the posts on stackoverflow and cannot seems to find what I am looking for.

If I do (Form:

$.ajaxSettings.dataType    = "jsonp";
$.get('http://MYREMOTESERVER.com/GetCustNewID.asp?callback=?', function() {
     //SOMETHING HERE
     });

On The remote CLASSIC ASP server how, using asp, would I return the id?

This Response.Write "[{""id"": " & Rs("@ID") & "}]" obviously does not work.

Thanks for your help.


回答1:


Here is the correct way to return jsonp using classic asp. We are not returning json, we are returning json wrapped in a javascript callback function so our response is javascript not json.

Response.ContentType = "application/javascript"

dim callback
callback = Request("callback") // callback querystring contains the callback function name

Response.Write(callback & "({""result"": ""Done""})")



回答2:


There may be an issue with cross-domain ajax depending on browser and/or server settings. I would make sure this is not the issue.




回答3:


For those who want to know. The Answer is here: http://forum.jquery.com/topic/classic-asp-and-jsonp-output



来源:https://stackoverflow.com/questions/6449575/using-classic-asp-to-return-data-to-jsonp-call

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!