Is it possible to disable AJAX without disabling JavaScript completely?

前端 未结 8 2197
傲寒
傲寒 2020-12-28 21:52

Is it possible to disable AJAX without disabling JavaScript completely?

相关标签:
8条回答
  • 2020-12-28 22:44

    No. AJAX is just a particular use of javascript.

    If you could block the particular function call back to the server you might be able to do it, but you would probably have to edit your browser.

    I assume you want to do this from the client end... Can you list some more specific goals? What is the expected outcome?

    0 讨论(0)
  • 2020-12-28 22:46

    If you are using Firefox, you could accomplish this with GreaseMonkey. (https://addons.mozilla.org/en-US/firefox/addon/748)

    GM is a framework for applying scripts to some or all of the pages you visit. I have GM scripts that disable google-analytics downloads (because they slow things down), and which disable google-click-tracking on google result pages (because it bothers me that they are doing that).

    Here is my google-click disable script:

    // ==UserScript==
    // @name           Google Clk
    // @namespace      googleclk
    // @description    Disable Google click tracking
    // @include        http://*google.com/*
    // ==/UserScript==
    // Override google's clk() function, which reports all clicks back to google
    unsafeWindow.clk = function(url) {} // { alert(url); } // I use this to test.
    

    By doing something similar with XMLHttpRequest (and other functions) you can effectively disable them. Of course, you may completely break the page by doing this, but you already knew that.

    0 讨论(0)
提交回复
热议问题