View Full Version : ajax - status 0 or 200?
fairuz.ismail
02-22-2008, 08:50 AM
Just a question about ajax fundamental, i know that to check if the response is served correctly we should check xmlhttp.status == 200 .But is it true that if we working with local files, we must use 0 instead of 200?
thanks.
mjlorbet
02-22-2008, 09:02 AM
anything coming out of an xhr request should have a status of 200 & a readystate of 4 if it's been properly received, regardless of origin because the request is going out on the xhr object assuming it's looking to a server. if you're talking about accessing a file on a user's machine, then it's perhaps better to use a cookie instead, or just cache your session or user data in a database, create a webservice or a passthrough page to extract your data from. most browsers will alert the user if the website they're on is attempting to access their machine. most people frown on this. moreover, if the file is already on the user's machine, there's no need to use an xhr for it, the file is already ready to go.
nikku
02-22-2008, 11:26 AM
Just a question about ajax fundamental, i know that to check if the response is served correctly we should check xmlhttp.status == 200 .But is it true that if we working with local files, we must use 0 instead of 200?
thanks.
hello fairuz,
Ya its true that if you are using a local file the status will be 0.
rnd me
02-22-2008, 12:30 PM
i find it easier to simply check for responseText...
its only there when you want to apply the event.
fairuz.ismail
02-22-2008, 05:50 PM
hello fairuz,
Ya its true that if you are using a local file the status will be 0.
thanks for clarifying this for me tho.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.