0

AJAX 调用有问题。我认为这个大而时髦的函数本质上会返回一个是/现在的字符串。

usdaurl = 'http://eligibility.sc.egov.usda.gov/eligibility/eligibilityservice?eligibilityType=Property&requestString=<?xml version="1.0"?><Eligibility xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="/var/lib/tomcat5/webapps/eligibility/Eligibilitywsdl.xsd"><PropertyRequest StreetAddress1="'+street+'" StreetAddress2="" StreetAddress3="" City="'+city+'" State="'+state+'" County="" Zip="'+zip+'" Program="RBS"></PropertyRequest></Eligibility>';
$.ajax({
    url: usdaurl,
    dataType: 'XML',
    success: function(xml){
        var usda = $('Property').attr('Eligibility');
    }
});

这是简单的版本,我已将问题深入到此功能。这是我不断收到的错误:

XMLHttpRequest cannot load http://eligibility.sc.egov.usda.gov/eligibility/eligibilityservice?eligibil…%2262034%22%20Program=%22RBS%22%3E%3C/PropertyRequest%3E%3C/Eligibility%3E. 
Origin http://[mydomain ;)] is not allowed by Access-Control-Allow-Origin. 

查询尝试访问的 URL 有效。如果我只是把它放到浏览器中,我会得到一些 XML。但是当我尝试使用 AJAX 时,我得到了这个错误。

4

1 回答 1

2

不允许 Ajax 开箱即用地调用其他域。有一些特定于浏览器的解决方法。

于 2013-03-05T05:48:33.203 回答