0
I have the following ajax :
$(".select").change(function()
{
var select = $("#selectAparelho").val();
$.ajax({
async: false,
type: "POST",
url: "administrador.php",
data: aparelho = select
}).done(function (data) {
console.log(aparelho);
});
return false;
});
The problem is that when my php server checks to see if the variable is null:
if (isset($_POST['aparelho']))
The server checks that it is null because at that time it has not yet received the value, so it returns that it is null and then does not go through that chunk of code to do the check again. What I need is a way to get the server to go through that code location again to check if the variable is empty again, by that time it will already be with the value it received from ajax and then it will perform the operation I wish.
I think the correct one would be: date: {device: select}
– Wallace Maxters
You are returning
aparelho
in thedone
, but it should bedata
. Takes theasync
, otherwise it is not ajax.– Diego Souza
I marked the question as a typo. Although my reply received two upvotes, I think it would be fair to turn it into comment.
– Wallace Maxters
The async was just a desperate test heheh, now I’m printing my date in the log, and is bringing everything I need, only with a problem, in the log this right but is not ataualizado on the screen, as I do to update on the screen the information?
– Roberto Albino
You can A) Locate the elements in the page DOM using $("#minhaid") $(". minhaclasse") or similar mechanisms and then B) use a change of the element value or internal text of the element or add elements dynamically. I answered a similar question a few days ago: http://answall.com/questions/170469/filtro-c-ajax-php/170723#170723 More about: http://www.w3schools.com/jquery/jquery_dom_add.asp https://learn.jquery.com/using-jquery-core/manipulating-elements/
– Antonio Alexandre