javascript error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • codeseeker1
    New Member
    • Jan 2009
    • 14

    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
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    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

    Comment

    • codeseeker1
      New Member
      • Jan 2009
      • 14

      #3
      here is my js code..
      Code:
      function change(src,str)
      {    alert(src)
          var cntrl;
          if(src=="department")
          {
              myAjax.open("GET", "Ajax_EditDetails.php?src="+src+"&val="+str);
              myAjax.onreadystatechange = function()
              {
      --code--
                                       }
      if(src=="packing")
          {
              //alert(src)
              myAjax.open("GET", "Ajax_EditDetails.php?src="+src+"&val="+str);
              myAjax.onreadystatechange = function()
              {--code--
      }
      }
      Last edited by acoder; Jan 20 '09, 08:33 AM. Reason: Added [code] tags

      Comment

      • codeseeker1
        New Member
        • Jan 2009
        • 14

        #4
        javascript not working without an alert box

        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
        Code:
        function change(src,str)
        {	alert(src)
        	var cntrl;
        	if(src=="department")
        	{
        		myAjax.open("GET", "Ajax_EditDetails.php?src="+src+"&val="+str);
        		myAjax.onreadystatechange = function()
        		{<---code-->
        }if(src=="packing")
        	{
        		myAjax.open("GET", "Ajax_EditDetails.php?src="+src+"&val="+str);
        		myAjax.onreadystatechange = function()
        		{<-- -->
        }
        }
        when alert(src) is removed packing and department details are not getting.can anyone help?

        thanks in advance

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          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)

          Comment

          • codeseeker1
            New Member
            • Jan 2009
            • 14

            #6
            sorry ..i forgot to include the code

            Code:
            function change(src,str) 
            {    alert(src) 
                var cntrl; 
                if(src=="department") 
                { 
                    myAjax.open("GET", "Ajax_EditDetails.php?src="+src+"&val="+str); 
                    myAjax.onreadystatechange = function() 
                    { 
            --code-- 
                                             } 
            if(src=="packing") 
                { 
                    //alert(src) 
                    myAjax.open("GET", "Ajax_EditDetails.php?src="+src+"&val="+str); 
                    myAjax.onreadystatechange = function() 
                    {--code-- 
            } 
            } 
            
            myAjax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            myAjax.send(null);
            Last edited by gits; Jan 20 '09, 11:28 AM. Reason: added code tags

            Comment

            • gits
              Recognized Expert Moderator Expert
              • May 2007
              • 5388

              #7
              threads merged .... please don't double post the same questions

              regards,
              MOD

              Comment

              Working...