如何在php发送的ajax中接收和使用json? [英] How to receive and use a json in ajax sended from php?
本文介绍了如何在php发送的ajax中接收和使用json?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从php到ajax接收json,并希望访问json中的不同字段值.
I want to receive json from php to ajax and want to access the different field values in json.
推荐答案
在jQuery中,它将实现以下内容:
In jQuery it will be implementing something like this:
var user = {};
$.ajax({
url: 'http://mysite.com/api/user.json',
data: {'id': '42'},
success: function(data){user = data;},
});
$('#name').val(user.name);
$('#email').val(user.email);
这篇关于如何在php发送的ajax中接收和使用json?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文