Java Script Error when using Ajax in php.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • svsenthilkumar
    New Member
    • Dec 2007
    • 11

    Java Script Error when using Ajax in php.

    Hai,

    I got an javascript error when using ajax in mozilla browser, anyone help me why the error is coming, meaning for this error and how can i rectify this error.


    Error: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_A VAILABLE) [nsIXMLHttpReque st.status]" nsresult: "0x80040111 (NS_ERROR_NOT_A VAILABLE)" location: "JS frame :: (here url)
  • svsenthilkumar
    New Member
    • Dec 2007
    • 11

    #2
    Java Script Error when using Ajax in php.

    Hai,

    I got a javascript error when using ajax with php, in mozilla browser, functionality wise it works properly. but i get this error, anyone help me why the error is coming, meaning for this error and how can i rectify this error.


    Error: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_A VAILABLE) [nsIXMLHttpReque st.status]" nsresult: "0x80040111 (NS_ERROR_NOT_A VAILABLE)" location: "JS frame :: (here url)

    Comment

    • gits
      Recognized Expert Moderator Expert
      • May 2007
      • 5388

      #3
      threads merged since they cover the same issue ... please don't double post your questions

      kind regards

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Without posting code, we can only guess. Post your code.

        Comment

        • svsenthilkumar
          New Member
          • Dec 2007
          • 11

          #5
          Originally posted by acoder
          Without posting code, we can only guess. Post your code.

          I got a javascript error when using ajax with php, in mozilla browser, functionality wise it works properly. but i get this error, anyone help me why the error is coming, meaning for this error and how can i rectify this error.


          Error: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_A VAILABLE) [nsIXMLHttpReque st.status]" nsresult: "0x80040111 (NS_ERROR_NOT_A VAILABLE)" location: "JS frame :: (here url)


          In code "divClass2" is another drop down, this is also, i am getting using ajax.
          i am getting the same error in this ajax code also.


          Here is the codes
          ~~~~~~~~~~~~~

          itemlist.php
          -------------------

          [CODE=javascript]<script>
          function ddlClass1(val)
          {
          if(val==0)
          {
          document.getEle mentById('divCl ass2').style.di splay='none';
          }
          if(val != 0)
          {

          var http = createRequestOb ject();
          http.open('GET' ,'itemadd.php?i d='+val);
          http.onreadysta techange = function()
          {
          if(http.readySt ate == 4 && http.status == 200)
          {

          var response = http.responseTe xt;
          // alert(response) ;
          if(response)
          {

          document.getEle mentById('divCl ass1').style.di splay='';
          document.getEle mentById('divCl ass2').style.di splay='none';
          document.getEle mentById("divCl ass1").innerHTM L = response;

          }
          }
          else
          {
          document.getEle mentById("divCl ass1").innerHTM L="Error code " + http.status;
          }
          }

          http.send(null) ;


          }
          }



          function createRequestOb ject()
          {
          var req;
          try
          {
          // Firefox, Opera 8.0+, Safari
          req=new XMLHttpRequest( );
          }
          catch (e)
          {
          // Internet Explorer
          try
          {
          req=new ActiveXObject(" Msxml2.XMLHTTP" );
          }
          catch (e)
          {
          try
          {
          req=new ActiveXObject(" Microsoft.XMLHT TP");
          }
          catch (e)
          {
          alert("Your browser does not support AJAX!");
          return false;
          }
          }
          }
          return req;
          }

          </script>
          [/CODE]

          [HTML]<form >
          <table>
          <tr class="text1">
          <td>Items Add </td>
          <td>
          <select name="type123" class="txtfield " OnChange="ddlCl ass1(this.value )">
          <option value="0">--Select Item--</option>
          <?
          include "dbconnect.inc" ;
          $retsql="select * from itemmaster";
          $exect=mysql_qu ery($retsql);
          while( $row=mysql_fetc h_row($exect))
          {
          $id=$row[0];
          $name=stripslas hes($row[1]);

          echo "<option value=\"$id\">$ name</option>";
          }
          mysql_close();
          ?>
          </select><br />
          <div id="divofclass1 " style="display: none"></div>
          <div id="divClass1" style="display: none" ></div>
          <div id="divClass2" style="display: none" ></div>
          </td></tr>
          </table></form>

          [/HTML]=============== =============== =============== =============== =======


          itemadd.php (AJAX)
          ------------------------------

          [PHP]<?
          include "dbconnect.inc" ;
          $sqltypeitem="s elect count(*) from itemmaster where typeid=$id and typename='other '";
          $exectype=mysql _query($sqltype item) or die("invalid query123" .mysql_error()) ;
          $countnumber=my sql_result($exe ctype,0,"count( *)");
          if ($countnumber!= 1)
          {
          $sqlcount = "select count(*) from itemsubmaster where itemid=$id";
          $resultcount = mysql_query($sq lcount);
          $count1=mysql_r esult($resultco unt,0,"count(*) ");
          if ($count1!=0)
          {
          ?>
          [/PHP][HTML] <select name="subtype12 3" class="txtfield " onchange="ddlCl ass2(this.value )">
          <option value="0">--Select Sub Item --</option>[/HTML]
          [PHP] <?
          $retsql="select * from itemsubmaster where itemid=$id";
          $exect=mysql_qu ery($retsql);
          while( $row=mysql_fetc h_row($exect))
          {
          $id=$row[0];
          $name=stripslas hes($row[2]);
          echo "<option value=\"$id\">$ name</option>";
          }
          ?>
          </select>

          <? }

          else {
          ?>
          [/PHP][HTML] <script>
          document.getEle mentById('divCl ass1').style.di splay='';
          document.getEle mentById('divCl ass2').style.di splay='';
          </script>[/HTML]
          [PHP]<? }

          }
          else {
          ?>
          [/PHP][HTML] <input type="text" class="txtfield " name="otherof" onblur="otherva lueof(this.valu e)" >
          <script>
          document.getEle mentById('divof class1').style. display='';
          document.getEle mentById('divCl ass1').style.di splay='none';
          document.getEle mentById('divCl ass2').style.di splay='none';
          </script>[/HTML]
          [PHP]<?
          }
          mysql_close();
          ?>[/PHP]

          =============== =============== =============== =============== =======
          Last edited by acoder; Dec 24 '07, 08:53 AM. Reason: Added code tags

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            What line does this error occur on? I'm guessing it occurs on this line:
            Code:
            if(http.readyState == 4 && http.status  == 200)
            Correct?

            Please use code tags when posting code.

            Comment

            • svsenthilkumar
              New Member
              • Dec 2007
              • 11

              #7
              Originally posted by acoder
              What line does this error occur on? I'm guessing it occurs on this line:
              Code:
              if(http.readyState == 4 && http.status  == 200)
              Correct?

              Please use code tags when posting code.


              Sorry for the late reply


              The component return failure error is coming in the javascript of line is 32

              [Code=javascript]
              <script>
              function ddlClass1(val)
              {
              if(val==0)
              {
              document.getEle mentById('divCl ass2').style.di splay ='none';
              }
              if(val != 0)
              {

              var http = createRequestOb ject();
              http.open('GET' ,'itemadd.php?i d='+val);
              http.onreadysta techange = function()
              {
              if(http.readySt ate == 4 && http.status == 200)
              {

              var response = http.responseTe xt;
              // alert(response) ;
              if(response)
              {

              document.getEle mentById('divCl ass1').style.di splay ='';
              document.getEle mentById('divCl ass2').style.di splay ='none';
              document.getEle mentById("divCl ass1").innerHTM L = response;

              }
              }
              else
              {
              document.getEle mentById("divCl ass1").innerHTM L="Error code " + http.status;
              }
              }

              http.send(null) ;


              }
              }
              [/code]
              Last edited by acoder; Mar 19 '08, 11:11 AM. Reason: fixed code tag

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                See if this thread from the archives helps.

                Note that to use code tags, you just need to wrap them using the # button, e.g.
                [code=javascript]your code here&#91;/code]

                Comment

                Working...