1
私はこの{"test1":"My first test","test2":"my second test"}
jqueryのAJAXは、CodeIgniterの
のような文字列値は、私が二<div>
に1 <div>
とtest2
でtest1
を表示するように努めました複数のdivの値が使用していることを解析します。しかし、私は未定義になっています。
以下は私のjqueryスクリプトです。
function getListOfProduct(val) {
// alert(val)
// $("#search-box").val(val);
$("#suggesstion-box").hide();
var parent = $(this);
$.ajax({
type: "POST",
datatype: "json",
cache: false,
url: base_url+'subscription/subscription/ajax_list_product',
data:'prodid='+val,
async: false,
success:function(res)
{
$("#listproduct").html(res.test1);
$("#new").html(res.test2);
},
error: function (XHR, status, response) {
//alert(data);
alert('fail');
}
});
}
誰でも教えてください。
ありがとうございます!あなたの方法で購読/購読/ ajax_list_productから
私はあなたの応答が要素の配列で構成されていると思うし、結果をhtmlオブジェクトに追加する前に 'res [0] .test1' –
を試してみると、応答は正しい形式、すなわち行$( "#listproduct")の前です。html(res.test1);行警告を追加する(JSON.stringify(res));過去のアラート結果はこちら –
res [0] .test1と$( "#listproduct").html(res.test1);私のために働いていません。 – premi