添加查询字符串URL的Ajax调用字符串、URL、Ajax

2023-09-10 17:54:46 作者:我哭肿的眼

我想KN是有可能通过查询字符串与URL时,我们jQuery的Ajax调用;

I wanna kn is it possible to pass query string along with URL when we call on Jquery Ajax;

例如:

    $.ajax({
           type: "POST",
           url: "index.php?task=addNewInfo",
           data: $('#regForm').serialize(),
           dataType: "json",
              .....
      });  

所以呢从参数任务的查询字符串正常工作?或者我们需要做的其他方式? 谢谢你。

So does the query string from the param task works fine? or we need to do it the other way? Thank you.

推荐答案

发送任务中的数据参数

data:"task=addNewInfo&" + $('#regForm').serialize()

这是使用POST方法。 如果你想使用GET方法,那么阿朗的解决方案将正常工作。

This is for using POST method. If you want to use GET method then Arun's solution will work fine.