1
I이 {"test1":"My first test","test2":"my second test"}
JQuery와 AJAX는 CodeIgniter의
같은 문자열 값 I가 제 <div>
하나 <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