tags:

views:

26

answers:

1

Hi Guys,

I am using JQuery and I have below code.

 $("#departure_city").change(function() 
            {                         
                $.ajax(
                {
                type:'post',
                url: '/specialoffers.aspx',
                data: { city: $(this).val() },
                success: function(result) 
                {
                    $("tab-container").find(".borderContainer").html((result).find('#tab-container').find('.borderContainer').html);
                }
                });
            });   

I want to update particular div html got from the ajax result html, I am trying with some below logic, but it is not working for me. Here I am looking to take particular div html from ajax result.

$("tab-container").find(".borderContainer").html((result).find('#tab-container').find('.borderContainer').html);

Please suggest!

+1  A: 

You're missing a # on your first selector, $ on your second and () on your .html() call, like this:

$("#tab-container").find(".borderContainer").html($(result).find('#tab-container').find('.borderContainer').html());

A bit simple would be like this:

$("#tab-container .borderContainer").html($(result).find('#tab-container .borderContainer').html());

Or use .replacewith() like this:

$("#tab-container .borderContainer").replaceWith($('#tab-container .borderContainer', result));
Nick Craver
Cleaner version would be something like:var selector = "#tab-container .borderContainer"; $(selector).html($(result).find(selector).html());
Neil
I want to show the ajax loading.gif also till the result is fetch from the post data
MKS
@MKS - Just call `.show()` or `.fadeIn()` or whatever you want before the `$.ajax()` call, and a `.hide()` or `.fadeOut()`, etc in your `success` callback.
Nick Craver
Thanks but from where I can get the loading.gif ID, I mean where I need to put the image code..please suggest
MKS
@MKS - Just give the `<img>` or `<div>` or whaterver it is an ID, or use something more sophisticated like blockUI. If you're looking for where to find actual images: http://ajaxload.info/
Nick Craver