jquery – 为什么我的POST变量出现在URL字符串上?

前端之家收集整理的这篇文章主要介绍了jquery – 为什么我的POST变量出现在URL字符串上?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经基于按钮点击实现了ajax post功能.代码
$.ajax({
    type: "POST",url: "includes/PHPscripts?action=manage",data: {location: loc,lat: latitude,lon: longitude,heading: head,filename: file},success: function(){
      $("#panoInfo").html("<div id='message'></div>");
      $("#message").html("Valid Submission");
  }
});

我指定了POST方法,因为我不希望通过URL看到变量.但是,他们是.

我发布之前的测试网址是

http://localhost/JMCTour/buildtour.PHP

然后

http://localhost/JMCTour/buildtour.PHP?filename=1-prefix_blended_fused.jpg&location=Start+of+Tour&lat=43.682211&long=-70.450705&heading=100&submit=Save

为什么?

解决方法

docs for jQuery.ajax(强调我的):

data

Data to be sent to the server. It is converted to a query string,if not already a string. It’s appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be Key/Value pairs. If value is an Array,jQuery serializes multiple values with same key based on the value of the traditional setting (described below).

因此:

processDataBoolean

Default: true

By default,data passed in to the data option as an object (technically,anything other than a string) will be processed and transformed into a query string,fitting to the default content-type “application/x-www-form-urlencoded”. If you want to send a DOMDocument,or other non-processed data,set this option to false.

猜你在找的jQuery相关文章