JOlanare.AB
JOlanare.AB

Reputation: 37

No Ajax response even though URL is correct?

i get error in firebug when i try to get the data from the second url, but when i try the url in comments (the first one) everything is ok,

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);
               }    
         }); 

thanks for guidance

Upvotes: 0

Views: 57

Answers (1)

Daniel W.
Daniel W.

Reputation: 32290

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

must be

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

update:

enable cross domain requests: How to enable cross-domain request on the server?

debug:

success: function (data) { console.log(data); }

Upvotes: 2

Related Questions