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>
精彩评论