0

当我尝试从第二个 url 获取数据时,我在 firebug 中遇到错误,但是当我尝试评论中的 url(第一个)时,一切正常,

function build()
{ 
   $.ajax({
             type: "GET",
         contentType: "application/json",
         crossDomain: true,
         /// url: "http://localhost:9100/todo-0.1/data.json",
         url:'localhost:9000/rest/admin/component?componentUri=file:/home/workspace/app/5-Integration/',
              dataType: "json",
              success: function (data) 
                {
                 var n=data.links.link[1]['@href'].indexOf("file");
                 var ContObject=new Object();
                     ContObject.data=new Object();
                     ContObject.data["title"]= decodeURI(data.links.link[1]          ['@href'].substring(n));
                     ContObject.state="open";

                     ContObject.metadata=new Object();
                     ContObject.metadata["id"]= decodeURI(data.links.link[1]['@href'].substring(n));   
                 var jsonText = JSON.stringify(ContObject);
                 var output="<div>";
                     output+=  jsonText;
                     output+="</div>";
                     document.getElementById("placeholder").innerHTML=output;
                   alert("success");

                },
          error: function (data,status) 
               {
                  console.log("ERROR");
                  console.log(status);
               }    
         }); 

谢谢指导

4

1 回答 1

2

url:'localhost:9000/rest/admin/co....

一定是

url:'http://localhost:9000/rest/admin/co....

更新:

启用跨域请求:如何在服务器上启用跨域请求?

调试:

success: function (data) { console.log(data); }
于 2013-07-02T13:42:56.830 回答