有困難發送通過使用jQuery的Ajax功能後變量,改變類型時,得到的是所有的作品。JQuery的Ajax請求不通過郵局發送變量
CODE
function loadAttributes() {
var selectedValues = [];
var presentValues = [];
$('#attrplaceholder div').each(function(){
if (typeof $(this).data('attrid') !== 'undefined')
{
presentValues.push($(this).data('attrid'));
}
});
$("#categories :selected").each(function(){
selectedValues.push($(this).val());
});
jQuery.ajax({
url: 'backend.php?r=products/setProductAttributes',
type: "POST",
dataType:"html",
contentType: 'text/html; charset=utf-8',
data: {ids: selectedValues,presentids: presentValues},
success: function(json){
alert(json)
if(json!='[]'){
var obj = eval ("(" + json + ")");
if(obj.json !== 'undefined'){
$.each(obj.json, function(k, v) {
if(k==='views'){
$("#attrplaceholder").append(v);
}
if(k==='rem'){
var remvals = v.toString().split(",");
for(i=0;i<remvals.length;i++){
$("#attrgrp_"+remvals[i]).remove();
}
}
});
}
}
}
});
return false;
}
loadAttributes()
$("#categories").on("change",function(){
loadAttributes()
});
任何指針會有所幫助,我試圖與CONTENTTYPES玩,仍然沒有運氣
如果使用Firebug或Chrome開發工具,您是否可以檢查網絡調用並查看您的AJAX調用是否具有請求負載中的數據? –
添加'error'回調函數,並登錄'textStatus' – dcodesmith
@DavidHoerster - 請求有效載荷發送以下數據IDS%5B%5D = 6&IDS%5B%5D = 16&IDS%5B%5D = 13,所以數據是被髮送 – Roland