Possible problems and solutions with jQuery
When working with JavaScript, we can have more problems than not having JavaScript available; for example, the called URL not being available, a timeout, or something similar.
That can be quite inconvenient for our visitors, especially if they don't know
that something bad has happened. Taking our mod_littlecontact
as
an example again, this module uses the following script to make the AJAX
call:
$.post("index.php", $("#sc_form").serialize(), show_ok());
Instead of writing this URL, misspell it as follows:
$.post("inde.php", $("#sc_form").serialize(), show_ok());
Well, you can give it a try, but I would like to tell you that no errors will occur. All will work as expected, except that the mail will not be sent.
This can be quite a problem when developing, as we won't really know where the error is happening. But think about our visitors; they will see the "mail sent ok" message, which is not true.
Of course, we can do something about this. For example...