I have searched a lot and done many tests but I am not able to send the value of a Javascript variable to a PHP variable.
My case is as follows: I have a real estate portal and would like to get the information (more precisely the real estate data or just the name of it) searched for by a Javascript function and move to a variable in PHP, in case the variable $title
, which is the variable that regulates the title that will appear on each page in the browser.
The JS function that takes this information is this:
function getDadosImobiliaria(id) {
$.getJSON('../site/Control/controlUsuario.php', {type: 'selectDadosImob', imobiliariaId: id}, function(data) {
if (data.tipo == "f") {
var imobiliaria = data.nome+" "+data.sobrenome;
$('.nomeAnunciante').html(imobiliaria);
} else {
var imobiliaria = data.sobrenome;
$('.nomeAnunciante').html(imobiliaria);
}
$('#logoAnunciante').attr('src', 'imagensUpload/'+data.logo);
$('.ruaNumero').html(data.rua+', '+data.numero);
$('.bairro').html(data.bairro);
$('.cidadeUf').html(data.cidade+' - '+data.uf);
$('#fone').html(data.fone);
$('.showCidade').html(data.cidade);
$('.showCidade').attr('href', '/imobiliarias/'+data.cidade);
$('.countTotalImoveis').html(data.count);
if (data.creci != undefined) {
$('.creci').html("CRECI: "+data.creci);
}
});
}
How can I make to pass the real estate variable or any other variable to the PHP $title
variable contained in another file and thus form the title pages of the real estate portal? By POST
? Ajax?
Thank you in advance!