如何使用jqueryajax检索数据
控制台中的响应=>如何使用jqueryajax检索数据,jquery,ajax,codeigniter,Jquery,Ajax,Codeigniter,控制台中的响应=>[{“id”:“23”,“name”:“fh”,}]您需要如下解析JSON响应: $(document).on('click','#edit',function(){ var id = $(this).attr('value'); $.ajax({ type:'post', url:"http://localhost/CI-Ajaxold/register/show/"+id, }).done
[{“id”:“23”,“name”:“fh”,}]
您需要如下解析JSON
响应:
$(document).on('click','#edit',function(){
var id = $(this).attr('value');
$.ajax({
type:'post',
url:"http://localhost/CI-Ajaxold/register/show/"+id,
}).done(function(data){
console.log(data);
});
});
然后,您可以根据需要通过迭代循环或任何其他方式来使用它
谢谢,希望它能帮助你 请尝试以下代码:
$(document).on('click','#edit',function(){
var id = $(this).attr('value');
$.ajax({
type:'post',
url:"http://localhost/CI-Ajaxold/register/show/"+id,
}).done(function(data){
let response = $.parseJSON(data);
// here you can use response variable as needed.
});
});
这回答了你的问题吗?你能提供更多的细节吗?谢谢你的回答谢谢你的回答
$.ajax({
type:'post',
url:"http://localhost/CI-Ajaxold/register/show/"+id,
success: function(result){
//use result here
}});