Advertisement Jump to content
Sign in to follow this  

Javascript using data from another location

This topic is 5123 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does anyone here know javascript really well? I am trying to figure out if it is a valid option for a project that I am working on. Basically I need to know if it is possible for javascript to request data from an outside source and embed it in a website. Ideally it would be great to just be able to open up a tcp connection and send a request/hear a response then parse it and store it in the page in place of variables. However, we could also get by with doing something like making a request for a separate file (xml probably) and then parse the file an insert the data into the page. Does anyone know if this is possible? Also, how good is javascript with working with binary operations (bit shifts and masking), arrays and float/doubles?

Share this post

Link to post
Share on other sites
What you want to take external data in javascript is XMLHttpRequest. However this is not part of any standard and is only supported by some browsers.

Moreover, it doesn't behave identically in different browsers, just in a similar fashion.

Originally it was an ActiveX object shipped with IE5 - but because it was so useful, Mozilla adopted it, followed by Opera (And I believe Safari / Konqueror may have it in latter versions too).

How "good" is javascript with working with binary operations? Really about as good as anything else. javascript doesn't have separate int, float and double types, but rather has a Number type which behaves like them all (probably really a double).

Arrays are objects in javascript which happen to have integer indexes for their elements. You can create (an empty) one by using new Array(7) (7 is the length).

All objects behave like associative arrays, so you can initialise a blank one with new Object(), or use initialisers like

var myobj = { a:42, b:99, c:"Hello" };

Which would create an object with those properties (so myobj.a == 42 etc).


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!