Return php values with javascript

2

In java I did a project that in several parts of the program called a function to go to the database to fetch a value and return, of type String nome = acessocliente.obtemnome(id); , where in the accesclient class I had a parameter called getname that returned the name of the customer by id. Home Well I wanted to do this in JavaScript and PHP. Home That is somewhere in the JavaScript code calling the php of type var nome = "obtemnome.php?id="+id; Home How can I do this?

    
asked by anonymous 11.05.2016 / 11:12

1 answer

0

I could do this:

$("#div_qualquer").load("obtemnome.php",{id:id}, function(response){
   alert(response); //alerta a resposta obtida do PHP
});

The only change I made in your code was to pass the parameters via POST to PHP, however, if you prefer to pass via GET itself, just revoke this {id:id} ;

    
24.05.2016 / 16:30