[英]Can I add a comment to an ajax call that's visible in fiddler when I look at what gets sent out?
I have code like this:我有这样的代码:
$.ajax({
cache: false,
url: "/xx"
}).done(onAjaxDone).fail(function (jqXHR, textStatus, errorThrown) {
Dialog.Alerts.ajaxOnFailure(jqXHR, textStatus, errorThrown);
});
and和
$.ajax({
cache: false,
url: "/xxxxx"
}).done(onAjaxDone).fail(function (jqXHR, textStatus, errorThrown) {
Dialog.Alerts.ajaxOnFailure(jqXHR, textStatus, errorThrown);
});
When I check with fiddler I notice more than one ajax call.当我查看 fiddler 时,我注意到不止一个 ajax 调用。 Is there some way I can add some meta to the ajax calls that would not be used but that would allow me to see where the call is coming from in my code.
有什么方法可以向 ajax 调用添加一些不会被使用的元数据,但这样我就可以在我的代码中查看调用的来源。 Something like a comment that I could place within the ajax() and that would be visible going across the network?
像我可以放置在 ajax() 中并且在整个网络中可见的评论之类的东西?
You could send some meta-data in a non-standard header, using the headers
option:您可以使用
headers
选项在非标准标头中发送一些元数据:
$.ajax({
//...
headers: { MyCustomHeader: "Location #1" }
});
Then check for it on the server side using Request.Headers["MyCustomHeader"]
.然后使用
Request.Headers["MyCustomHeader"]
在服务器端检查它。
You could also append a key to the query string, but I suppose using an HTTP header is less invasive.您还可以在查询字符串中附加一个键,但我认为使用 HTTP 标头的侵入性较小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.