开发者

get a spesific html on return jquery ajax post

$('#form-register').change(function() {
    var i_username = $('input#input-username').val();
    var i_password = $('input#input-password').val();
    var i_company  = $('input#input-company').val();
    var i_phone    = $('input#input-phone').val();
    $.post("home", { 
        username : i_username,
        password : i_password,
        company  : i_company,
        phone    : i_phone,
        register : 'helloworld' 
    }, fu开发者_如何学Gonction(return_data){
        $('body').html(return_data);
    });
});

ok the question maybe is on the $('body').html(return_data); can we get a specific html from the return data ? example #errordiv that contains my error list if exist then somehow append on my page ? or is there another better way to do it ?

Thanks for looking in,

Adam Ramadhan


$(return_data) will give you html structure

and $(return_data).find('#errordiv') will give you "error div" element


yes u can append errordiv

<ul id="tmp">
<li>Name</li>
<li>Address</li>
</ul>

then use

$('<li>Error</li>').prependTo('#tmp');

will give

<ul id="tmp">
    <li>Error</li>
<li>Name</li>
<li>Address</li>
</ul>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜