1

I have an object defined in a .js file, which is done via PHP on the server side.

I would like to know how to set a variable equal to this object, because the JS file doesn't actually define anything, it is just the object...

EX: (this is my .js file on my server)

{  
"Title": {"Link" = "http://example.com", "img" = "http://imgurl.com"},
 "Title2": {"Link" = "http://blahblah.com", "img" = "http://imgurl.com"}
}

1 Answers1

1

This is what we call a JSON file. You can parse it with JSON.parse.

As for how to get the content of the file dynamically, you could use the JQuery function getJSON or work the AJAX yourself, but I don't know a lot about that.

Domino
  • 6,314
  • 1
  • 32
  • 58