2014-10-07 35 views
0

//沒有「訪問控制允許來源」標題存在於所請求的資源。因此,原產地「_example__」是不允許訪問

大段引用我想通過一個Web API來訪問JSON內容。我可以訪問的內容,但由於某種原因,它給了我錯誤 :「沒有‘訪問控制允許來源’標頭出現在 請求的資源,因此產地'http://localhost'不允許 訪問。」現在,它意味着,我必須讓一些CORS或 如何移動內容相同的域。

我不知道如果我要上啓用它:原始服務器(請求) 在這種情況下,本地主機B:在外部服務器或C:我必須設置 了一些代碼在我的Ajax調用

請諮詢和指導,以正確的內容爲我有點*******的 這方面。

<script> 
     jQuery(document).ready(function() { 
      jQuery('#34f8l4frywio').change(function(){ 
       if((jQuery("#34f8l4frywio").length < 0) || (jQuery("#vnkt3fpocr10").length < 0)){ 

       }else{ 
        var newserial = jQuery("#34f8l4frywio").val(); 
        var newmodel = jQuery("#vnkt3fpocr10").val(); 
        jQuery.ajax({ 
         url : 'http://example.com/xmlrpc/serial_json.php?serial='+ newserial+'&model='+ newmodel + '&format=json', 

         dataType: "text", 
         contentType: "text/plain", 
         xhrFields: { 
          withCredentials: false 
          }, 
         //here it fails and gives the error 
         success: function(data) { 
          var json = $.parseJSON(data); 

           jQuery('#6bun045yhogr').val(json[0].warranty); 
           jQuery('#34f8l4frywio').val(json[0].serial); 
           jQuery("#vnkt3fpocr10").val(json[0].model); 
         } 
        }); 
       } 
      }); 
     }); 
    </script> 

回答

相關問題