Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-10-2011, 07:07 PM   PM User | #1
esthera
Senior Coder

 
Join Date: May 2004
Posts: 1,432
Thanks: 14
Thanked 0 Times in 0 Posts
esthera can only hope to improve
jquery

sometimes when running

$.ajax({
url: urltoajax,
cache: false,
success: function(html) {
$("#formfields").html(html);
}
});

in jquery from a link

meaning i call my javascript function on click of the link - instead of replacing the div it ads a new one with the new content
it should replace the div called #formfields
esthera is offline   Reply With Quote
Old 03-10-2011, 08:19 PM   PM User | #2
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
Quote:
Originally Posted by esthera View Post
sometimes when running

$.ajax({
url: urltoajax,
cache: false,
success: function(html) {
$("#formfields").html(html);
}
});

in jquery from a link

meaning i call my javascript function on click of the link - instead of replacing the div it ads a new one with the new content
it should replace the div called #formfields
put your code between [ code] and [ /code] tags, please.

try this way:
Code:
 $.ajax({
            url: urltoajax,
            cache: false,
            success: function(data) {
                $("#formfields").replace(data);
            }
        });
best regards
oesxyl is offline   Reply With Quote
Old 03-10-2011, 08:27 PM   PM User | #3
esthera
Senior Coder

 
Join Date: May 2004
Posts: 1,432
Thanks: 14
Thanked 0 Times in 0 Posts
esthera can only hope to improve
this gives me an error
esthera is offline   Reply With Quote
Old 03-10-2011, 08:33 PM   PM User | #4
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
Quote:
Originally Posted by esthera View Post
this gives me an error
i didn't test it, and now i just look thru jquery docs, is replaceWith

http://api.jquery.com/replaceWith/

try this and if you get an error, post the error to.

Edit: forget to say, was my fault,

best regards
oesxyl is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:16 AM.


Advertisement
Log in to turn off these ads.