It's not a secret anymore!*
The moose likes HTML, CSS and JavaScript and the fly likes Help needed in using Ajax.request (prototype.js API) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Help needed in using Ajax.request (prototype.js API)" Watch "Help needed in using Ajax.request (prototype.js API)" New topic
Author

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

Chitresh Katarpawar
Greenhorn

Joined: Feb 08, 2010
Posts: 2
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

Joined: Jan 10, 2002
Posts: 60780
    
  65

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.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Help needed in using Ajax.request (prototype.js API)
 
Similar Threads
Pressing the enter key receive extra invalid data
Ajax in JSp
Problem getting servlets working
Ajax in JSP
A problem in hiding a button