从php中的url获取xml数据

时间:2014-01-21 11:32:03

标签: php html xml jquery

我需要一个帮助,我在提交表单后有一个表单,操作url将xml数据返回给浏览器,我想将xml数据转换为变量。无法取,我试着按照代码

$( "#searchForm" ).submit(function( event ) {
$.ajax({
        type: "GET",
        url: "my_remote_url",
        dataType: "xml",
        success: xmlParser
    });

})
function xmlParser(xml) {
console.log(xml);
}

在控制台上显示访问控制CORS错误,请指导我检索数据

1 个答案:

答案 0 :(得分:0)

试试这个:

//datatype:"xml",it is not needed
success: function(res){
alert(res);//this will alert the response if ajax is success.
}