EllisLab text mark
Advanced Search
     
Ajax.Request returned html
Posted: 28 August 2007 01:54 PM   [ Ignore ]
Avatar
Joined: 2007-08-21
7 posts

The following code displays ‘Login’ link. When its clicked, the request is passed and the returned text is ‘Hello’. Its confirmed using the Firebug’s Inspect tab.

<a onclick="new Ajax.Request('/user/loginajax',{onComplete:function(request){showResponse}, 
method:'get', evalScripts:true}); return false;" 
href="#">Login</a
function showResponse(req{
        
$('dologin')[removed] req.responseText;
        
alert('Call successful');
    

The following is the div that should get updated with the returned ‘Hello’ text. But this div’s content doesn’t change. And the alert(‘Call successful’) also doesn’t gets called.

<div id="dologin">nothing</div

Can you please figure out the missing in the above code?
Thanks.

 
Posted: 29 August 2007 04:57 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2007-03-12
221 posts

you have not assigned the req.responseText to the innerHTML property of the DIV.

obiron

 Signature 

There are 10 kind of people in this world, those who understand binary and those who don’t

 
Posted: 29 August 2007 05:41 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2007-07-24
82 posts

Your onComplete should read like this:

onCompleteshowResponse 
 
Posted: 31 August 2007 02:02 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2007-08-21
7 posts

@ deviant
Thanks. That was the culprit.

@ obiron2
I’d put that but this forum’s backend just made it [removed]

 
Posted: 31 August 2007 08:12 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2006-06-17
151 posts

Whay don’t you use the Ajax.Updater() function to acheive the same effect in one go?

 Signature 

CodeCrafter - Open Source Code Generation for CI

 
Posted: 01 September 2007 11:08 AM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2007-08-21
7 posts
Crafter - 01 September 2007 12:12 AM

Whay don’t you use the Ajax.Updater() function to acheive the same effect in one go?

Yup, sure I’m using it. But this one was just for the testing purpose.
Can you please help me out with this one below:
Prototype Modal Window Redirection problem
Thanks.