Welcome Guest, Not a member yet? Register   Sign In
Ajax.Request returned html
#1

[eluser]millisami[/eluser]
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.
Code:
<a onclick="new Ajax.Request('/user/loginajax',{onComplete:function(request){showResponse},
method:'get', evalScripts:true}); return false;" href="#"&gt;Login</a>
Code:
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.
Code:
<div id="dologin">nothing</div>
Can you please figure out the missing in the above code?
Thanks.
#2

[eluser]obiron2[/eluser]
you have not assigned the req.responseText to the innerHTML property of the DIV.

obiron
#3

[eluser]deviant[/eluser]
Your onComplete should read like this:

Code:
onComplete: showResponse
#4

[eluser]millisami[/eluser]
@ deviant
Thanks. That was the culprit.

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

[eluser]Crafter[/eluser]
Whay don't you use the Ajax.Updater() function to acheive the same effect in one go?
#6

[eluser]millisami[/eluser]
[quote author="Crafter" date="1188619936"]Whay don't you use the Ajax.Updater() function to acheive the same effect in one go?[/quote]
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.




Theme © iAndrew 2016 - Forum software by © MyBB