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

Java Script Error when using Ajax in php.

P: 11
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_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: (here url)
Dec 20 '07 #1
Share this Question
Share on Google+
7 Replies


P: 11
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_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: (here url)
Dec 20 '07 #2

gits
Expert Mod 5K+
P: 5,389
threads merged since they cover the same issue ... please don't double post your questions

kind regards
Dec 20 '07 #3

acoder
Expert Mod 15k+
P: 16,027
Without posting code, we can only guess. Post your code.
Dec 22 '07 #4

P: 11
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_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" 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
-------------------

Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function ddlClass1(val)
  3. {
  4.    if(val==0)
  5.    {
  6.         document.getElementById('divClass2').style.display='none';
  7.    }
  8.    if(val != 0)
  9.    {
  10.  
  11.         var http = createRequestObject();
  12.         http.open('GET','itemadd.php?id='+val);
  13.         http.onreadystatechange = function()
  14.         {
  15.             if(http.readyState == 4 && http.status  == 200)
  16.                 {
  17.  
  18.                 var response = http.responseText;
  19. //        alert(response);
  20.                 if(response)
  21.                  {
  22.  
  23.                     document.getElementById('divClass1').style.display='';
  24.                     document.getElementById('divClass2').style.display='none';
  25.                     document.getElementById("divClass1").innerHTML = response;
  26.  
  27.                  }
  28.                 }
  29.             else
  30.              {
  31.                 document.getElementById("divClass1").innerHTML="Error code " + http.status;
  32.              }
  33.             }
  34.  
  35.         http.send(null);
  36.  
  37.  
  38.     }
  39. }
  40.  
  41.  
  42.  
  43.     function createRequestObject()
  44.         {
  45.             var req;
  46.             try
  47.             {
  48.                     // Firefox, Opera 8.0+, Safari   
  49.                  req=new XMLHttpRequest();   
  50.             }
  51.           catch (e)
  52.             {   
  53.                  // Internet Explorer 
  54.                 try
  55.                     {
  56.                       req=new ActiveXObject("Msxml2.XMLHTTP");     
  57.                     }
  58.                 catch (e)
  59.                     {     
  60.                       try
  61.                           { 
  62.                             req=new ActiveXObject("Microsoft.XMLHTTP");       
  63.                           }
  64.                         catch (e)
  65.                           {      
  66.                              alert("Your browser does not support AJAX!"); 
  67.                              return false;     
  68.                           }  
  69.                     } 
  70.              }
  71.         return req;
  72.         }
  73.  
  74. </script>
  75.  
[HTML]<form >
<table>
<tr class="text1">
<td>Items Add </td>
<td>
<select name="type123" class="txtfield" OnChange="ddlClass1(this.value)">
<option value="0">--Select Item--</option>
<?
include "dbconnect.inc";
$retsql="select * from itemmaster";
$exect=mysql_query($retsql);
while( $row=mysql_fetch_row($exect))
{
$id=$row[0];
$name=stripslashes($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="select count(*) from itemmaster where typeid=$id and typename='other'";
$exectype=mysql_query($sqltypeitem) or die("invalid query123" .mysql_error());
$countnumber=mysql_result($exectype,0,"count(*)");
if ($countnumber!=1)
{
$sqlcount = "select count(*) from itemsubmaster where itemid=$id";
$resultcount = mysql_query($sqlcount);
$count1=mysql_result($resultcount,0,"count(*)");
if ($count1!=0)
{
?>
[/PHP][HTML] <select name="subtype123" class="txtfield" onchange="ddlClass2(this.value)">
<option value="0">--Select Sub Item --</option>[/HTML]
[PHP] <?
$retsql="select * from itemsubmaster where itemid=$id";
$exect=mysql_query($retsql);
while( $row=mysql_fetch_row($exect))
{
$id=$row[0];
$name=stripslashes($row[2]);
echo "<option value=\"$id\">$name</option>";
}
?>
</select>

<? }

else {
?>
[/PHP][HTML] <script>
document.getElementById('divClass1').style.display ='';
document.getElementById('divClass2').style.display ='';
</script>[/HTML]
[PHP]<? }

}
else {
?>
[/PHP][HTML] <input type="text" class="txtfield" name="otherof" onblur="othervalueof(this.value)" >
<script>
document.getElementById('divofclass1').style.displ ay='';
document.getElementById('divClass1').style.display ='none';
document.getElementById('divClass2').style.display ='none';
</script>[/HTML]
[PHP]<?
}
mysql_close();
?>[/PHP]

================================================== =================
Dec 24 '07 #5

acoder
Expert Mod 15k+
P: 16,027
What line does this error occur on? I'm guessing it occurs on this line:
Expand|Select|Wrap|Line Numbers
  1. if(http.readyState == 4 && http.status  == 200)
Correct?

Please use code tags when posting code.
Dec 24 '07 #6

P: 11
What line does this error occur on? I'm guessing it occurs on this line:
Expand|Select|Wrap|Line Numbers
  1. 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

Expand|Select|Wrap|Line Numbers
  1.       <script>
  2.       function ddlClass1(val)
  3.       {
  4.          if(val==0)
  5.          {
  6.               document.getElementById('divClass2').style.display  ='none';
  7.          }
  8.          if(val != 0)
  9.          {
  10.  
  11.               var http = createRequestObject();
  12.               http.open('GET','itemadd.php?id='+val);
  13.               http.onreadystatechange = function()
  14.               {
  15.                   if(http.readyState == 4 && http.status  == 200)
  16.                       {
  17.  
  18.                       var response = http.responseText;
  19.       //    alert(response);
  20.                       if(response)
  21.                        {
  22.  
  23.                           document.getElementById('divClass1').style.display  ='';
  24.                           document.getElementById('divClass2').style.display  ='none';
  25.                           document.getElementById("divClass1").innerHTML = response;
  26.  
  27.                        }
  28.                       }
  29.                   else
  30.                    {
  31.                       document.getElementById("divClass1").innerHTML="Error code " + http.status;
  32.                    }
  33.                   }
  34.  
  35.               http.send(null);
  36.  
  37.  
  38.           }
  39.       }
  40.  
Mar 19 '08 #7

acoder
Expert Mod 15k+
P: 16,027
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[/code]
Mar 19 '08 #8

Post your reply

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