如何从jQuery中的ajax发布结果中找到div html [英] How to find the div html from the ajax post result in jquery

查看:54
本文介绍了如何从jQuery中的ajax发布结果中找到div html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JQuery,并且具有以下代码.

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);
                }
                });
            });   

我想更新从ajax结果html中获取的特定div html,我尝试使用以下一些逻辑,但对我来说不起作用.在这里,我希望从ajax结果中获取特定的div 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);

请提出建议!

推荐答案

您在第一个选择器上缺少了#,在第二个选择器上缺少了$,并且在

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());

有点简单,就像这样:

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

或使用 .replacewith() 像这样:

Or use .replacewith() like this:

$("#tab-container .borderContainer").replaceWith($('#tab-container .borderContainer', result));

这篇关于如何从jQuery中的ajax发布结果中找到div html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆