Mootools request - can't get examples to work

I have downloaded examples for both Request and Request.HTML and cant get any work or work done. I unpacked them into a folder and looked at their index.html to execute them as they are, but the response is always "Request failed". without any indication as to why.

I've played with them with different permutations and can get the request, but it always fails. Is there a way to get the reason for the failure? I tried three different browsers, turned off my firewall, used relative and absolute file links, but nothing seems to work. Am I missing something obvious? I would post the code, but these are exactly the same examples ...

Any help would be awesome.

Greetings,

Justin.

+1


source to share


4 answers


If I recall correctly, AJAX requests in most browsers cannot be made through the local file system - you need a real web server like Apache. On Windows, XAMPP will run Apache in minutes.



+1


source


Most web servers should work. It's just that your filesystem doesn't "respond" to browser requests like a web server does:

Ajax requests that are done locally (against the filesystem) don't work well because the ajax logic looks for a state and server change, neither of which are provided by your filesystem

- http://forum.mootools.net/viewtopic.php?id=5009



The XMLHttpRequest object can handle not only HTTP requests, but at least in mootools, this is not intended. And "file: /// ..." is not an HTTP request. It just takes a file from your filesystem and displays it in the browser.

So, the good news: any web browser, even bare bones, running on your local machine should work fine :)

+1


source


Brilliant !! Thank you so much! I have uploaded it to the nearest web server and of course it works.

I tried to make some Ajax calls directly from my filesystem without any javascript libraries - using XMLHttpRequest () - and it worked fine, so it looks like a weird limitation. Can I be sure this will always work from any web server, however it may be? It's just that this project I'm working on will use multiple hosting environments, mostly just regular HTML type sites for client environments that I have no control over ... Is there a minimum specification?

Greetings;)

0


source


XMLHttpRequest()

succeeds because nothing happens to the local call. this is completely different and the problem is in the bugy mootools function isSuccess

. You must override it with options Request

. Here's how jquery does it

    // Determines if an XMLHttpRequest was successful or not
httpSuccess: function( xhr ) {
    try {
        // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
        return !xhr.status && location.protocol === "file:" ||
            // Opera returns 0 when status is 304
            ( xhr.status >= 200 && xhr.status < 300 ) ||
            xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
    } catch(e) {}

    return false;
},

      

0


source







All Articles