php - jQuery ajax mysql select doesn't work -
hello i'm trying mysql query ajax based on 2 select options in joomla component i'm working on.
i don't want post whole html shortend it. checked values passed trough php nothing in return.
so php , js:
<html> <head> <!-- load necessary files here --> </head> <?php function firstquery(){ if(isset($_post['adr'])){ $one = $_post['adr']; //adr name of first select $two = $_post['toadr']; //toadr name of second select $db = jfactory::getdbo(); $query = $db->getquery(true); $query->select(array('range', 'time', 'cost')); $query->from('#__transfer_rang'); $query->where('from="'.$one.'" , to="'.$two.'"'); $db->setquery($query); $results = $db->loadobjectlist(); print_r($results); exit; } } firstquery(); ?> <body> <script> $(function=(){ $("#click").click(function () { $.ajax({ type: "post", data: $("#myform").serialize(), success: function(data){ $('#test').html(data); } }); }); }); </script> <div id="test"> </div> <form id="myform" method="post" action=""><!-- form stuff here --></form> </body>
what missing?
Comments
Post a Comment