不允许使用AJAX

时间:2013-03-05 05:46:52

标签: ajax

遇到AJAX调用问题。我认为这个大而时髦的功能本质上为字符串提供了一个yes / now。

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时,我收到了这个错误。

1 个答案:

答案 0 :(得分:2)

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