arvgta / ajaxify

Ajaxify - An Ajax Plugin
https://4nf.org/
275 stars 124 forks source link

Ajaxify forms: Graceful degradation #70

Closed arvgta closed 9 years ago

arvgta commented 9 years ago

At the moment, when ajaxifying a form fails, the user's form may become dysfunctional. There is only the possibility to exclude it manually from the ajaxification process.

I reckon, it would be more elegant to "fall back" to a non-ajaxified form in case of failure. (The form would then function, even if it is not ajaxified...)

Current situation:

In the case of

The goal is obviously to maximise the success cases, by maximising the potential handling of all kinds of forms...


I have tried embedding the code in try + catch instead, but it doesn't work... Here's the code I tried:

    try {
        p = _k();
        var g = "get",
        m = fm.attr("method");
        if (m.length > 0 && m.toLowerCase() == "post") g = "post";

        var h, a = fm.attr("action");
        if (a && a.length > 0) h = a;
        else h = currentURL; 

        $.rq("i");
        $.rq("s", h);

        if (g == "get") h = _b(h, p);
        else {
            $.rq("is", true);
            $.rq("d", p);
        }

        } catch(e) { $.log("a form could not be ajaxified"); return true; };

The $.log message is never written to the console...


So now, I reckon, there ought to be some kind of validation code, instead of the

try... catch...

arvgta commented 9 years ago

Closing this with the note, that forms can be disabled by selecting them out manually.

Please re-open, if you have ideas / feedback...