5
I have a function AJAX:
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 the PHP:
echo '<div id="userReturn">"'.$valor.'"</div>';
That one div
will be inserted inside a menu as specified in result
of AJAX:
success: function(result) {
$("#loader").hide();
$("#user-painel-2").html(result);
}
I must use the return always on JSON, or can I continue to do so without problems? What’s the difference between using the JSON and not HTML?
JSON are structured data in a different way. Returning how you are returning is in HTML format. If you return in JSON it gets complicated you return the HTML in it. The way you are doing is right.
– Diego Souza
I have a system here that I return a page in AJAX.
– Diego Souza
In fact there is virtually no difficulty in transforming a json into html @Gumball it can manipulate the json as you want
– Leo Letto