• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic