如何替换此json代码:
var contacts = [
{ firstName: 'Mohammed', lastName: 'Shurrab', phone: '0599000000' },
{ firstName: 'Osama', lastName: 'Abu Kmail', phone: '0599111111' },
{ firstName: 'Alaa', lastName: 'Saqer', phone: '0599666666' }
];
从jquery ajax调用(getJson)到以下返回json的url的结果:
amerenaya.com/CI/index.php/hello/example5
并将结果存储在变量联系人中?
在javascript代码中使用?
答案 0 :(得分:0)
var contacts;
$.getJSON('http://amerenaya.com/CI/index.php/hello/example5').success(function(data) {
contacts = eval(data);
});