XoSilenceoX Posted March 13, 2008 Share Posted March 13, 2008 I am creating a registration form that uses php to validate the content. The problem Im running into is that the function is don onblur. so when someone completes a field it progresses & progresses to the next it will start a check. The problem im running into is that if someone types fast or changes fields quickly via the mouse or tab it cancels the previous request if they have not completed. Im using the following ajax script. var http = false; if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); } function register_ajax(Varea,Vlink) { http.abort(); document.getElementById(Varea).innerHTML = '<img src="images/ajax_loading_small.gif">'; http.open("GET", Vlink, true); http.onreadystatechange=function() {if(http.readyState == 4) { document.getElementById(Varea).innerHTML = http.responseText; } } http.send(null); } Heres a 2 part example of the form I am using. <table width="450" border="0" cellpadding="5" cellspacing="0" style="border:1px solid #CCCCCC; font-weight:bold;"> <tr> <td width="1%" align="left" valign="middle" nowrap="nowrap"><img src="images/information.gif" width="16" height="16" /></td> <td width="1%" align="left" valign="middle" nowrap="nowrap">EMAIL ADDRESS:</td> <td align="center" valign="middle"> <input type="text" name="EMAIL" id="EMAIL" class="sitetext" style="width:100%" onblur="register_ajax('checkemail','register/email.php?check=' + this.value); " /></td> <td width="1%" align="center" valign="middle"><div id="checkemail"></div></td> </tr> <tr> <td colspan="2" align="left" valign="middle" nowrap="nowrap">VERIFY EMAIL:</td> <td align="center" valign="middle"><input name="VEMAIL" type="text" class="sitetext" id="textfield6" style="width:100%" onblur="register_ajax('checkvemail','register/vemail.php?check=' + this.value + '&check2=' + document.register.EMAIL.value);"/></td> <td width="1%" align="center" valign="middle"><div id="checkvemail"></div></td> </tr> </table> Any help would be greatly appreciated. This is a very big project for me and I am trying to figure this out as soon as possible. Thanks. If you want to see a working example of the problem go to http://sincitybeats.magicalfta.com and click on the coming soon. Then click on the Register link. I have tried changing the loading image to an onstate change event and still same results. Quote Link to comment Share on other sites More sharing options...
priti Posted March 13, 2008 Share Posted March 13, 2008 hi http.abort(); is aborting your request and what you are facing is the problem faced by many.I always prefer to make only one ajax request and then send it over the server and get the response in mean time you can show the waiting faiure too.If there is possibility of network cogestion then the validation will behvae very differently. so once user fills up the form create a signle ajax request and populate your error_string and show accordingly. Quote Link to comment Share on other sites More sharing options...
XoSilenceoX Posted March 13, 2008 Author Share Posted March 13, 2008 hi http.abort(); is aborting your request and what you are facing is the problem faced by many.I always prefer to make only one ajax request and then send it over the server and get the response in mean time you can show the waiting faiure too.If there is possibility of network cogestion then the validation will behvae very differently. so once user fills up the form create a signle ajax request and populate your error_string and show accordingly. I tried to remove the http.abort(); also sorry didnt state that in the first post. It still gets the same results. I know this is possible as google maps uses the same command and just coords to identify which image to load. Anyone got any solutions. Even a different script all together i can work with. Quote Link to comment Share on other sites More sharing options...
XoSilenceoX Posted March 13, 2008 Author Share Posted March 13, 2008 Sorry guys, gals but I solved the problem The Ajax script I got from http://www.dhtmlgoodies.com/index.html?whichScript=ajax-dynamic-content worked perfectly. If you want to try it out check out my previous post for the link. But it allows for each one to be a seperate request without cancels. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.