问题
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