0

I'm trying to get the JSON from this URL into variable

This bit of code successfully puts it in a div element

$("#siteloader").html('<object data="MYURL">');

But I want the contents of that div inside a string variable rather than in the div.

I've also tried the following:

$.ajax({
    type : "GET",
    dataType : "jsonp",
    url : "MYURL", // ?callback=?
    success: function(data){
        // do stuff with data
    }
});

But this shows a syntax error "Uncaught SyntaxError: Unexpected token : " "getfixes:1" in the javascript console when I try it in chrome.

Is it possible for me to just get the contents of a URL as a string in the data variable?

2
  • it seems the json returned from url is illegal. open the url in browser and try to assign the result to a var in the console. like the following: var obj = //paste the result from url you'll get an error. Commented Jun 5, 2014 at 15:51
  • It seems like it! Can I retrieve it as a string? Surely if I retrieve the JSON as a string it shouldn't have parsing errors right? I don't know how to retrieve it as a string though :/ Commented Jun 5, 2014 at 15:57

1 Answer 1

0

there is a external library according to this post: String URL to json object

http://james.padolsey.com/javascript/parsing-urls-with-the-dom/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.