I am in JS and ajax is not strong, I ask for help. Task: there is an input field input, and when changing the text in it, a new query should be made to the database, and the sample should be based on the entered text in the field, I try to do this:
$('#street').on('input keyup', function(e) { var name_st = this.value; <? $sql_streetj = mysql_fetch_assoc(mysql_query("SELECT * FROM `street` WHERE `name_ru` = 'ТУТ ЗНАЧЕНИЕ ПЕРЕМЕННОЙ ИЗ name_st'")); $sl2 = array(); $all_city_db2 = mysql_query("SELECT * FROM `houses` WHERE `id_street` = '$sql_streetj[id]'"); while ($city_name_ru2 = mysql_fetch_assoc($all_city_db2)) { $sl2[] = $city_name_ru2['name_ru']; } ?> }); I can't insert the value of a variable from JS: name_st , everything should happen without reloading the page. I would be very grateful for the help!
<?worth writing as<?php- Naumovvar name_st = this.value;is executed on the client by the browser, and the code between<? ... ?><? ... ?>- on the server. - Igor