Answer the question
In order to leave comments, you need to log in
How to pass two data parameters to ajax.done?
Good afternoon, I have ajax sends search data and outputs with
$users = $wpdb->get_results( "SELECT * FROM table WHERE ".$user_filter." ORDER BY ID DESC" );
foreach ($users as $u ){
if ($u->user_status == 1){
$status = '<span class="profile_status">VIP</span>';
}else{
$status = '';
}
if($u->user_customid == ''){
$userID = $u->ID;
}else{
$userID = $u->user_customid;
}
echo '
<div class="profile_card">
<div class="profile_avatar">
<div class="img_wrapper">
<a href="pagedonor?id='.$u->ID.'"><img src="'.$u->user_microavatar.'" alt="userAvatar"></a>
</div>'.$status.'
</div>
<div class="profile_info">
<p>Donor ID: <span>'.$userID.'</span></p>
<p>Age: <span>'.$u->user_age.'</span></p>
</div>
</div>
';
}
$('#filters').submit(function(event) {
event.preventDefault();
var filterData = $(this).serialize();
$.ajax({
url: 'filter.php',
type: 'POST',
data: filterData,
})
.done(function(data) {
$('.profiles_wrapper').html(data);
var _hrefs = '#profiles';
$("html, body").animate({scrollTop: $(_hrefs).offset().top+"px"});
})
.fail(function() {
console.log("error");
})
.always(function() {
console.log("complete");
});
});
Answer the question
In order to leave comments, you need to log in
In this case, you can’t do without json, since AJAX receives a string in response one way or another, and passing two strings will not work without a crutch (Well, there’s like a separator, etc.). The bottom line is this: on the PHP side you respond with a json string, and on the client you parse the string and process it as needed ...
But, something tells me that you partially want to receive the same data from the server that you send to the server
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question