Adding a parameter to the URL with JavaScript

后端 未结 30 2590
刺人心
刺人心 2020-11-22 07:33

In a web application that makes use of AJAX calls, I need to submit a request but add a parameter to the end of the URL, for example:

Original URL:

30条回答
  •  野性不改
    2020-11-22 08:11

    This is a simple way to add a query parameter:

    const query = new URLSearchParams(window.location.search);
    query.append("enabled", "true");
    

    And that is it more here.

    Please note the support specs.

提交回复
热议问题