0

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

Aleks G
  • 56,435
  • 29
  • 168
  • 265
JOlanare.AB
  • 37
  • 1
  • 10
  • 2
    *i get error in firebug* - OK. What is the error you get in firebug? – Sean Bright Jul 02 '13 at 13:39
  • i get error in console, and Object { readyState=0, status=0, statusText="error"} – JOlanare.AB Jul 02 '13 at 13:54
  • what do you get as output by `success: function (data) { console.log(data); }` – Daniel W. Jul 02 '13 at 13:57
  • i get nothing, if i use this url, and i don't know why – JOlanare.AB Jul 02 '13 at 14:00
  • i tried http:// localhost:9000/rest/admin/co... also but doesn't work – JOlanare.AB Jul 02 '13 at 14:04
  • if you get nothing, then the error is inside `localhost:9000/rest/admin/component?componentUri=file:/home/workspace/app/5-Integration/`document. when you access this by browser, you get nothing too? Does the server on port 9000 allow cross domain requests? – Daniel W. Jul 02 '13 at 14:19
  • yes,when i access by the brower i get my data. Can you explain what do you mean by the server allows cross domain requests.thank you – JOlanare.AB Jul 02 '13 at 14:48
  • i add a new parameter in error: function (data,status,errorThrown){ console.log(errorThrown);} and i get this error [Exception... "Failure" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://localhost:9100/todo-0.1/jquery-1.7.2.min.js :: :: line 4" data: no] { name="NS_ERROR_FAILURE", message="Failure", result=2147500037, more...} – JOlanare.AB Jul 02 '13 at 14:50
  • http://stackoverflow.com/questions/6871021/how-to-enable-cross-domain-request-on-the-server – Daniel W. Jul 02 '13 at 14:50

1 Answers1

2

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); }
Community
  • 1
  • 1
Daniel W.
  • 31,164
  • 13
  • 93
  • 151
  • i have used two servers. i run my application using port :9000 and so i want to get data from http://localhost:9100. so i can't . finally, i solved the problem, by using just one server 9100. thank you all for help – JOlanare.AB Jul 07 '13 at 21:26