473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Ajax is not giving response when Firebug is off..........

rpnew
188 100+
Hi,
I'm facing this problem. I'm developing a tool in PHP/MySql with litle bit use of Ajax. At once place i've used Ajax function for validation purpose . But my problem is when my firebug is off/disabled Ajax dosent show any response and i get the wrong messages. But when firebug is on/enabled then it shows the proper output. What could be the problem?
If you want to see the code then i can paste it here.


Regards,
RP
Jan 29 '08 #1
10 2134
acoder
16,027 Expert Mod 8TB
Either post the code or a link to a test page.
Jan 29 '08 #2
rpnew
188 100+
Either post the code or a link to a test page.
Hi,
Here is the Ajax code..
Expand|Select|Wrap|Line Numbers
  1. <!-- Function for HTTPRequest object-->
  2. function getHTTPObject() 
  3.     var xmlhttp; 
  4.     if (window.ActiveXObject) 
  5.     {
  6.         try 
  7.         {
  8.             xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  9.         }
  10.         catch (e)
  11.         {
  12.             try
  13.             {
  14.                 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  15.             }
  16.             catch (E) 
  17.             {
  18.                 xmlhttp = false;
  19.             }
  20.         }
  21.     } 
  22.     else
  23.     {
  24.         xmlhttp = false;
  25.     }
  26.     if (window.XMLHttpRequest) 
  27.     {
  28.         try
  29.         {
  30.             xmlhttp = new XMLHttpRequest();
  31.         } 
  32.         catch (e) 
  33.         {
  34.             xmlhttp = false;
  35.         }
  36.     } 
  37.     return xmlhttp; 
  38. }
  39.  
  40. <!-- Function for checking duplicate names....-->
  41.     function validatenames()
  42.     {
  43.         var htpobj = getHTTPObject();    
  44.         var str = document.mod_form.Mod_Name.value;
  45.         var pname=document.mod_form.Prod_Name.value
  46.         url='checknames.php?mname='+str+'&pname='+pname;
  47.         htpobj.open("GET", url, false);
  48.         htpobj.onreadystatechange = function()
  49.                         {
  50.                             if (htpobj.readyState == 4) 
  51.                             {
  52.                                 if(htpobj.responseText == 1)
  53.                                 {
  54.                                     alert(htpobj.responseText);
  55.                                     document.getElementById('vlnames').value=0;
  56.                                     document.mod_form.Mod_Name.focus();
  57.  
  58.                                 }
  59.                                 else
  60.                                 {
  61.                                     document.getElementById('vlnames').value=1;
  62.                                     alert(htpobj.responseText);
  63.                                     document.mod_form.Mod_Desc.focus();
  64.                                 }
  65.                             }
  66.                         }
  67.         htpobj.send(null);
  68.     }
  69.  
Here is where i'm calling it....
Expand|Select|Wrap|Line Numbers
  1. <!-- Function for checking blank fields....-->
  2.     function validate_form()
  3.     {
  4.         validatenames();
  5.         //document.write(document.feat_tab.width);
  6.         tr=true;
  7.         if(document.mod_form.Prod_Name.value == "")
  8.         {
  9.             tr = false;
  10.             alert('Product Id blank');
  11.             return tr;
  12.         }
  13.         else if(document.mod_form.Mod_Name.value == "")
  14.         {
  15.             tr = false;
  16.             alert('Module Name Field Can\'t Be Blank');
  17.             return tr;
  18.         }
  19.         else if(document.mod_form.vlnames.value==0)
  20.         {
  21.             tr=false;
  22.             alert('Duplicate Module Name Is Not Allowed');
  23.             document.mod_form.Mod_Name.focus();
  24.             return tr;
  25.         }
  26.         else
  27.         {
  28.             var agre=confirm('are you sure you want to submit the data???') ;
  29.             if(!agre) return false;
  30.             else 
  31.             {
  32.                 //refresh_feat_frame();
  33.                 return true;
  34.             }
  35.         }
  36.  
  37.     }
  38.  
And my PHP script just returns 0 and 1 if the name i'm sending to the scipt is present in database or not......

Now upto this point what i've done and what problem i've faced.....

As you can see i'm giving Ajax response to one TEXT field which i'm checking in form validation function.. If it has 0 then duplicate name is entered and if it is 1 then it means that user can submit the value.
Now first i tried the VALIDATENAMES() function itself in IF condition but as i didnt know how return something from Ajax function it was not working(If you can help me with that that would be good as well).
So what i did is i'm giving Ajax response to one textbox and then checking it for validation purpose.. Now what my problem is.....
I'm using firebug for javascrip/Ajax debugging.... now i've checked following four cases..

FireBug Enabled-Synchronuous Request


  • Works fine
FireBug Disabled-Synchronuous Request
  • No response from Ajax
FireBug Enabled-Asynchronuous Request
FireBug Disabled-Asynchronuous Request
  • Late response in both cases
One more thing i've learned through googling is this happens if you've not used your Ajax functions properly.... So in the last i would like to mention that what i want to do so if there is any another way you can guide me there...
Here i'm checking users input(name). If it is already there in database user will not be allowed to submit and if it is not there user can enter the value.....

Regards,
RP
Jan 30 '08 #3
acoder
16,027 Expert Mod 8TB
The responseText is a string, so you may want to parse or trim it. You should also check that the status is 200 (OK) before using the responseText.
Jan 30 '08 #4
rpnew
188 100+
The responseText is a string, so you may want to parse or trim it. You should also check that the status is 200 (OK) before using the responseText.
Hi,
I did that even but the problem is same let me write that again......

FireBug Enabled-Synchronuous Request
  • Works fine
FireBug Disabled-Synchronuous Request
  • No response from Ajax
FireBug Enabled-Asynchronuous Request
FireBug Disabled-Asynchronuous Request
  • Late response in both cases
So what could be the problem... and one more thing i would like t ask is .. is there any way to return something from Ajax function which we call by Onreadystatechange???

Regards,
RP
Jan 30 '08 #5
acoder
16,027 Expert Mod 8TB
The asynchronous requests are working fine - that is expected behaviour. The only time it doesn't seem to work is if Firebug is disabled during a synchronous request.

Why do you need a synchronous request anyway?
Jan 30 '08 #6
rpnew
188 100+
The asynchronous requests are working fine - that is expected behaviour. The only time it doesn't seem to work is if Firebug is disabled during a synchronous request.

Why do you need a synchronous request anyway?
Well..
Frankly i've not selected it...... but its only the working condition... as i've mentioned..
In Asynchronous requests the response are coming late then when i'm expecting........... and thats why i've used synchronous one......

Regards,
RP
Jan 30 '08 #7
acoder
16,027 Expert Mod 8TB
If you need to validate after the Ajax response, put the validation code in the onreadystatechange anonymous function after the ready state is 4.
Jan 30 '08 #8
rpnew
188 100+
If you need to validate after the Ajax response, put the validation code in the onreadystatechange anonymous function after the ready state is 4.
Hi,
yeah that should work.. Let me try it and i'll get back with the result....

Regards,
RP
Jan 30 '08 #9
rpnew
188 100+
Hi,
Thanks for your suggestion... i've changed my validation accordingly and now its working fine with all cases...

Regards,
RP
Jan 31 '08 #10
acoder
16,027 Expert Mod 8TB
Glad to hear that you got it working.
Jan 31 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ruso | last post by:
I am using ASP to make an application. What I want right now - is to make the self updating list of the users online - based on thier cookies. In my opinion all seems to be writen well with it's...
5
by: Steve Wright | last post by:
I have an AJAX routine on a webpage that is working in IE6, but not IE7 or Firefox v2.0.0.2 The webpage is http://www.a-drop-in-the-ocean.co.uk/CWS/monitor10bins.php?quarry=401 The AJAX...
4
by: Mike P2 | last post by:
Hi. To make page downloading quicker, I added GZipStream into the Response filter. My (shortened VB) code snippet from Global.asax looks like this: ............................................ ...
2
by: Gregor Kofler | last post by:
FireBug is without doubt a great utility for debugging JS, however with FireBug enabled my little AJAX scripts won't work properly. E.g. http://ajax.gregorkofler.at/index.php?page=tableedit In...
1
by: maildmz | last post by:
Goodafternoon, I have got a minimum Mongrel instance running (see ruby code) and i am hitting it with an Ajax request using Prototype. (see javascript code) I get the 'onLoading' event, but...
6
by: sheldonlg | last post by:
I came across a problem and googling for an answer didn't help. What I want to do is run an AJAX script that sets a hidden variable on the form. I call the AJAX script from a javascript...
6
by: raknin | last post by:
Hi I am running ajax call to my appache local server on my development server, which is also my testing server, I run the site from the server (the server running php,mysql), what I get back is a...
5
by: vasilis | last post by:
I have a list box in a site with which I capture a selected value with the onChange event using the capture_value() function (code listed below). This function passes 2 arguments, i.e., 'str' which...
5
by: MelindaM | last post by:
Hi guys, I created a form for searching through a parts library that I have stored in a MySQL database. I'm not new to web programming but this is my first time using PHP and Ajax. I have four...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.