Check if javascript works

Javascript coding ..

Moderators: macek, egami, gesf

faust
New php-forum User
New php-forum User
Posts: 109
Joined: Thu May 03, 2012 7:22 am

Check if javascript works

Postby faust » Tue May 15, 2012 7:05 am

My problem: I have 2 forms that use ajax - login and register. Everything works, if the user makes an error - an error popup shows. So my question is: is there a way to determine if the ajax request succeeded or something broke or maybe the user disabled his browsers js? If something like that occurs to submit the form the traditional way without ajax requests? Is there a way to check this?

User avatar
minimihi
New php-forum User
New php-forum User
Posts: 238
Joined: Sat Apr 14, 2012 11:57 am
Location: Vilnius, Lithuania

Re: Check if javascript works

Postby minimihi » Fri May 18, 2012 2:27 pm

You could use HTML <noscript> Tag to notify user to enable JavaScript. If JavaScript is not supported, only option (I think) would be to redirect user to page without JavaScript
like:

Code: Select all

<noscript>
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=http://www.some.org/form_without_JS.html">
</noscript>


As for AJAX (with jQuery). To check what happened with connection, you could use complete(), error() or success() functions.
jQuery.ajax()
In case it fails, you could submit form with JavaScript.

faust
New php-forum User
New php-forum User
Posts: 109
Joined: Thu May 03, 2012 7:22 am

Re: Check if javascript works

Postby faust » Mon May 21, 2012 7:13 am

Thanks, thats what I was going to do :)


Return to “JavaScript”

Who is online

Users browsing this forum: No registered users and 0 guests