我有JSON
如下输出:
["City1","City2","City3"]
Run Code Online (Sandbox Code Playgroud)
我想获得每个城市名称,我该怎么做?
$.getJSON("url_with_json_here",function(json){
});
Run Code Online (Sandbox Code Playgroud)
编辑:
$.getJSON('url_here', function(data){
$.each(data, function (index, value) {
$('#results').append('<p>'+value+'</p>');
console.log(value);
});
});
Run Code Online (Sandbox Code Playgroud)
以上似乎不起作用,没有输出值.
我有一个提供xml输出的URL.它需要一个用户名和密码,我可以使用以下格式通过浏览器访问:
但是,当我尝试通过php文件访问它时,我得到403禁止:
$url = "http://username:password@url.com";
$xml = @simplexml_load_file($url);
print_r($http_response_header);
Run Code Online (Sandbox Code Playgroud)
我已经尝试使用curl并将用户代理设置为浏览器,但这仍然不会回显数据.
编辑:
我也尝试过使用pear的http请求2,这也禁止了403