Skip to main content
gamedev.net
🔒 Locked

Javascript using data from another location

Started by DrjonesDW3d Jan 7, 2005 at 4:04 PM 0 replies 300+ views
Original Post
DrjonesDW3d
DrjonesDW3d
Does anyone here know &#106avascript 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 &#106avascript 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 &#106avascript with working with binary operations (bit shifts and masking), arrays and float/doubles?
markr
markr
What you want to take external data in &#106avascript 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 &#106avascript with working with binary operations? Really about as good as anything else. &#106avascript doesn't have separate int, float and double types, but rather has a Number type which behaves like them all (probably really a double).<br><br>Arrays are objects in &#106avascript which happen to have integer indexes for their elements. You can create (an empty) &#111;ne by using new Array(7) (7 is the length).<br><br>All objects behave like associative arrays, so you can initialise a blank &#111;ne with new Object(), or use initialisers like<br><pre><br><br>var myobj = { a:42, b:99, c:"Hello" };<br><br></pre><br><br>Which would create an object with those properties (so myobj.a == 42 etc).<br><br>Mark

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.