473,386 Members | 1,815 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,386 software developers and data experts.

javascript error

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
6 1080
gits
5,390 Expert Mod 4TB
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
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
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
8,658 Expert Mod 8TB
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
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
5,390 Expert Mod 4TB
threads merged .... please don't double post the same questions

regards,
MOD
Jan 20 '09 #7

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

Similar topics

8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.