+ 1

How to pass php to jQuery???

I have php query to get data from mysql. I want the results to be sent to my jQuery variable. var x = "<select>"+ <?php echo $phpQuery; ?>+"</select>"; $("p").append(x);

26th May 2017, 6:51 PM
Senzosihle Mbambo
Senzosihle Mbambo - avatar
2 ответов
+ 1
you have to use ajax. you should have a php code that outputs answer and a jQuery code that requests it and then you can store it in variable. https://www.w3schools.com/jquery/jquery_ajax_intro.asp for example you can see it in action at YouTube like button or in any ajax website like this one is simple http://mylink.rf.gd/1 it's made by me or you can also simply do this <form method="post" action="path-to-php.php"> <select></select> <button type=submit>get the menu</button> </form> or if you want the options to come then add a function as onclick of select box in that function it triggers a ajax request and the output will automatically be inserted inside it.
27th May 2017, 4:44 AM
Sandeep Chatterjee
0
Thanks.. it works
27th May 2017, 3:32 PM
Senzosihle Mbambo
Senzosihle Mbambo - avatar