AJAX如何從JSON方法
$('#stb_no').blur(function(){
var stb_no= $('#stb_no').val();
$.ajax({
url: "http://localhost/paymybill/ajax/stb_info",
global: false,
type: "POST",
data: {
'stb_no':stb_no, // you should give a key to the variable
},
success: function(data) {
$('#amount').val(data);
// $(".email_msg").addClass("red");
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
});
});
控制器代碼中的每個值
public function stb_info(){
$stb_no=$this->mso->alldata_stbno($this->input->post('stb_no'));
echo json_encode($stb_no);
}
我得到了把
[{"sxb_no":"xxxxxx","mzo_name":"xx","cto_name":"xxxxx","area":"xxxxx","name_sxb_owr":"","mobile_no":"xxxxxx","email":"[email protected]","amount":"xxx"}]
我需要知道如何讓每個值前: - 如果我想要獲得電子郵件ID我應該怎麼做jquery請幫我我新到ajax
取決於行返回的數字,但基本上:myArray的[0] [「電子郵件」] – sdespont
myArray的代表陣列名稱????但我沒有名字,我想我在文本框中顯示這個使用$('#amount')。val(data);在jquery – Anudeep