By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,481 Members | 1,213 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,481 IT Pros & Developers. It's quick & easy.

javascript error

P: 14
currently iam working with a php code along with ajax.
code works properly with an alert box.when alert box is removed,rest of code not working.can anyone help?

thanx in advance
Jan 19 '09 #1
Share this Question
Share on Google+
6 Replies


gits
Expert Mod 5K+
P: 5,390
please show the code ... typically this is a timing issue ... the alert halts the JS-execution until the response is ready and when you remove it it is not ... so we need to see your 'flow' to give you an advice for the correction

kind regards
Jan 19 '09 #2

P: 14
here is my js code..
Expand|Select|Wrap|Line Numbers
  1. function change(src,str)
  2. {    alert(src)
  3.     var cntrl;
  4.     if(src=="department")
  5.     {
  6.         myAjax.open("GET", "Ajax_EditDetails.php?src="+src+"&val="+str);
  7.         myAjax.onreadystatechange = function()
  8.         {
  9. --code--
  10.                                  }
  11. if(src=="packing")
  12.     {
  13.         //alert(src)
  14.         myAjax.open("GET", "Ajax_EditDetails.php?src="+src+"&val="+str);
  15.         myAjax.onreadystatechange = function()
  16.         {--code--
  17. }
  18. }
Jan 20 '09 #3

P: 14
hi all...
i've a php code code using ajax.Code is working properly with an alert box.but when alert box is removed,rest of code not working perfectly.code below
Expand|Select|Wrap|Line Numbers
  1. function change(src,str)
  2. {    alert(src)
  3.     var cntrl;
  4.     if(src=="department")
  5.     {
  6.         myAjax.open("GET", "Ajax_EditDetails.php?src="+src+"&val="+str);
  7.         myAjax.onreadystatechange = function()
  8.         {<---code-->
  9. }if(src=="packing")
  10.     {
  11.         myAjax.open("GET", "Ajax_EditDetails.php?src="+src+"&val="+str);
  12.         myAjax.onreadystatechange = function()
  13.         {<-- -->
  14. }
  15. }
when alert(src) is removed packing and department details are not getting.can anyone help?

thanks in advance
Jan 20 '09 #4

Dormilich
Expert Mod 5K+
P: 8,639
two things,
  1. the sync mode (sync/async) may be the wrong one (it's using default)
  2. you should actually send the request to get a response (using the send() function)
Jan 20 '09 #5

P: 14
sorry ..i forgot to include the code

Expand|Select|Wrap|Line Numbers
  1. function change(src,str) 
  2. {    alert(src) 
  3.     var cntrl; 
  4.     if(src=="department") 
  5.     { 
  6.         myAjax.open("GET", "Ajax_EditDetails.php?src="+src+"&val="+str); 
  7.         myAjax.onreadystatechange = function() 
  8.         { 
  9. --code-- 
  10.                                  } 
  11. if(src=="packing") 
  12.     { 
  13.         //alert(src) 
  14.         myAjax.open("GET", "Ajax_EditDetails.php?src="+src+"&val="+str); 
  15.         myAjax.onreadystatechange = function() 
  16.         {--code-- 
  17.  
  18. myAjax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  19. myAjax.send(null);
  20.  
Jan 20 '09 #6

gits
Expert Mod 5K+
P: 5,390
threads merged .... please don't double post the same questions

regards,
MOD
Jan 20 '09 #7

Post your reply

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