简体   繁体   English

如何显示AJAX HTTP请求收到的QueryString

[英]How to show the QueryString received by an AJAX HTTP Request

We have a script A which pulls information by sending an HTTPRequest to script B, with some GET parameters. 我们有一个脚本A,它通过使用一些GET参数向脚本B发送HTTPRequest来获取信息。

var URL = "http://domain.com/scriptB?ID="+ID;
var XMLGateway = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
    XMLGateway.open("GET", URL, false);
    XMLGateway.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

This script B then uses an ID in the querystring passed to it to return some information. 然后,此脚本B在传递给它的查询字符串中使用ID返回一些信息。 However this is inconsistently throwing errors. 但是,这始终会引发错误。

Some investigation shows instead of the ID we're passing in the GET (which always takes the format of a five digit number), it is using a string like ".sp-app-5" where the number has been 5-9 so far. 一些调查表明,我们使用的是“ .sp-app-5”之类的字符串,而不是我们在GET中传递的ID(它始终采用五位数的格式),因此该数字为5-9远。

String("["+Request("ID")+"]"); // [.sp-app-9]

I'm having trouble dealing with this bug as Request.QueryString used in script B is showing the QS that script A receives. 我在处理此错误时遇到了麻烦,因为脚本B中使用的Request.QueryString显示了脚本A收到的QS。 However, Request("ID") is returning the unusual string as above. 但是,Request(“ ID”)返回上面的异常字符串。

Server.HTMLEncode(Request.ServerVariables("HTTP_HOST")); // domain.com
Server.HTMLEncode(Request.ServerVariables("QUERY_STRING")); // scriptA?some=values&foo=bar (same result as Request.QueryString)

How can I show the querystring that script B is receiving in the HTTP Request? 如何显示HTTP请求中脚本B正在接收的查询字符串?

If I understand correctly, you need to verify that Script A is sending the GET Querystring in the request correctly. 如果我理解正确,则需要验证脚本A是否在请求中正确发送了GET Querystring。 For situations like this I often use a free tool called "Fiddler" from Telerek (on windows). 对于这种情况,我经常使用Telerek的免费工具“ Fiddler”(在Windows上)。 It will watch all your http calls and log the request and response, including the query string. 它将监视您的所有http调用并记录请求和响应,包括查询字符串。 Its pretty easy to install and is very useful when doing this type of project. 它非常容易安装,并且在进行此类项目时非常有用。

This will help you narrow down if script A is sending the ID correctly, or if Script B is interpreting the ID incorrectly. 如果脚本A正确发送了ID,或者脚本B错误地解释了ID,这将帮助您缩小范围。

Hope this helps! 希望这可以帮助!

提琴手输出示例

www.telerik.com/download/fiddler www.telerik.com/download/fiddler

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM