简体   繁体   English

当我查看发送的内容时,我可以向在 fiddler 中可见的 ajax 调用添加注释吗?

[英]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.

相关问题 如果注释掉成员的构造函数调用,为什么我的程序不起作用? - Why doesn't my program work if I comment out a member's constructor call? 当我在fiddler上查看帖子时,使用SSL /基本身份验证和标头将可见。 为什么? - Using SSL/basic authentication and headers appear visible when I view posts on fiddler. Why? 当我发送数据时,我写入TcpClient的NetworkStream? - When I Write to NetworkStream of TcpClient when data gets sent? 如果从Microsoft的代码中抛出异常,我如何找出最初导致异常的内容? - How do I find out what originally caused an exception, if it gets thrown from Microsoft's code? 我怎样才能看到发送的实际原始请求 - How can I the see actual raw request that gets sent 什么是Fiddler,如何关闭它? - What is Fiddler and how do I turn it off? 我正在尝试将记录插入到对象列表中,但在调用该方法时没有插入任何内容。 我究竟做错了什么? - I am trying to insert records into a an object list but nothing gets inserted when I call the method. What am I doing wrong? OPTIONS 获得 401,但在我使用 Fiddler 时却没有? - OPTIONS getting 401, but not when I use Fiddler? 我可以从C#开始小提琴吗? - Can I start fiddler from C#? 从 DateTime 切换到 DateTimeOffset 时需要注意什么? - Anything I need to look out for when switching from DateTime to DateTimeOffset?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM