Capturing ajax variables using php

Asked

Viewed 37 times

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.

  • 1

    I think the correct one would be: date: {device: select}

  • 1

    You are returning aparelho in the done, but it should be data. Takes the async, otherwise it is not ajax.

  • I marked the question as a typo. Although my reply received two upvotes, I think it would be fair to turn it into comment.

  • 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?

  • 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/

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.