I have an AJAX function:
function userCheck() {
var username = $("#username").html();
var userid = $("#balmung-id").val();
$.ajax({
url: "systems/usercheck.php",
type: 'POST',
data: {
username: username,
userid: userid
},
beforeSend: function() {
$("#loaderror").hide();
$("#loader").show();
},
success: function(result) {
$("#loader").hide();
$("#user-painel-2").html(result);
},
error: function() {
$("#loader").hide();
$("#loaderror").show();
},
timeout: 5000
});
}
It sends data and the return is done through a echo
in PHP :
echo '<div id="userReturn">"'.$valor.'"</div>';
This div
will be inserted into a menu, as specified in% AJAX%:
success: function(result) {
$("#loader").hide();
$("#user-painel-2").html(result);
}
Should I always use return in JSON , or can I continue doing this in a smooth way? What is the difference between using the data return in JSON and not HTML ?