Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Feb 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ajax - status 0 or 200?

    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.

  • #2
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    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.
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender

  • #3
    New Coder
    Join Date
    Feb 2008
    Posts
    19
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by fairuz.ismail View Post
    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.

  • #4
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,302
    Thanks
    10
    Thanked 586 Times in 567 Posts
    i find it easier to simply check for responseText...
    its only there when you want to apply the event.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #5
    New to the CF scene
    Join Date
    Feb 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by nikku View Post
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •