• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help needed in using Ajax.request (prototype.js API)

 
Chitresh Katarpawar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i am new in Ajax.request() and i need your help to solve my problem. i have used four attributes of ajax.request i.e. onFailure onCreate, onException and onComplete.

My HTML page is:---

<html>
<head>
<style type="text/css">
body
{
background: #C0C0C0;
font-family:sans-serif;
font-size: 26pt;
}

ul.dev={list-style-type: circle;}
</style>


<title>The HTML</title>

<script type="text/javascript" src="jquery-1.2.2.js"></script>
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="thejs.js"></script>
<script type="text/javascript">

function testdata()
{
var temp;
var xmlhttp;

alert("First FUnction");

new Ajax.Request("/xml/ab.xml",
{
onFailure:function()
{
alert("2nd function");
},

onCreate:function()
{
document.write("3rd function");
},

onException:function(req,exception)
{
alert("Exception Occured" + " " + exception);
},

onComplete:function(xhr)
{
temp.innberHTML = xhr.responseText;
alert("run");
}
});
}

function state_Change()
{
// if xmlhttp shows "loaded"
if (xmlhttp.readyState==4)
{
// if "OK"
if (xmlhttp.status==200)
{
//alert("Response"+xmlhttp.responseText);
temp.innerHTML = xmlhttp.responseText;
document.write(temp);
}
else
{
alert("Problem retrieving XML data");
}
}
}

</script>
</head>

<body>

<form>
<table>
<tr>
<th>Top <b>3</b> Developers of country</th>
<td>
<ul class="dev">
<li>Rahul Urane</li>
<li>Lokesh Paunikar</li>
<li> Saurab Soni</li>
</ul>
</td>
</tr>

<tr>
<td><input type="submit" id="submit" name="submit" value="submit" onclick="testdata()" /></td>
<td><input type="submit" id="getData" name="getData" value="Get Data!" onclick="abc()" /></td>
</tr>
</table>
</form>
</body>
</html>


on runing this HTML page in Browser i am getting my first alert and onCreate attribute is also runing well, but after onCreate excution of Ajax.Request() excution goes on onException instead of onComplete and raise the following exception.


My Exception is:---

Exception Occured [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.open]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://192.168.1.101:8080/tp-ls-formcontroller-example-0.0.1/html/prototype.js :: anonymous :: line 1215" data: no]


please help me to resolve this problem as soon as possible.

Thankh you.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65122
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the Firebug plugin of Firefox to see what's going on with the Ajax request. That might give you more clues as to why it's failing.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic