$.ajax获取不到数据问题解决
$("#updateflow").click(function () { $.ajaxSetup({ contentType: "application/json;charset=UTF-8" }); var flowData = $("#flowdata").val(); var flowData = JSON.parse(flowData); var param = { 'flowData': JSON.stringify(flowData['data']) }; $.post("/api/index.php/Habo_v2/DiyApi/updateFlowData", JSON.stringify(param), function (jsondata) { jsonStr = JSON.stringify(jsondata, null, 4); $("#flowdata").val(jsonStr); console.log("flowData: ", jsondata); }, "json"); });
获取不到数据时,记得 contentType的设置:
$.ajax({ type: "post", url: "getData.php", data: { Skip: Skip, Take: Take }, //contentType: "application/json; charset=utf-8",//(可以) //contentType: "text/xml",//(可以) //contentType:"application/x-www-form-urlencoded",//(可以) //dataType: "string", success: function (data) { if (data != "") { $('.thumb').append(data); } $('#divPostsLoader').empty(); } })
每天一小步,人生一大步!Good luck~