ajax post  data  获取不到数据,注意 content-type的设置 、post/get
关于 jQuery data 传递数据。网上各种获取不到数据,乱码之类的。
好吧今天我也遇到了,网上一查各种纠结。乱码不管先看获取不到数据。
因为之前一直用jQuery ajax get的方式传递参数, 默认没有设置过 contentType 的值。

 

 1      var Skip = 49; //Number of skipped row
 2      var Take = 14; //
 3      function Load(Skip, Take) {
 4           $('#divPostsLoader').html('<img src=http://www.update8.com/Web/Jquery/"ProgressBar/ajax-loader.gif">');
 5          //send a query to server side to present new content
 6          $.ajax({
 7               type: "get",
 8               url: "AjaxImage.ashx",
 9              data: { Skip: Skip, Take: Take },
10               //contentType: "application/json; charset=utf-8",//(可以)
11              //contentType: "text/xml",//(可以)
12               //contentType:"application/x-www-form-urlencoded",//(可以)
13              //dataType: "string",
14               success: function (data) {
15                   if (data != "") {
16                      $('.thumb').append(data);
17                   }
18                  $('#divPostsLoader').empty();
19               }
20           })
21      };
View Code

相关文章: