jquery - Popup doesnt show when using mysqli -


i'm creating form, results should showed in popup.

the query works, when combine popup doesn't. when use popup script alone doesn't show popup.

so quess problem popup.

//javascript $main .= '<head> <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script> </head>'; //end javascript 

-

//script <script> $(document).ready(function() {      $("#dialog").dialog({        autoopen: false,       show: {         effect: "blind",         duration: 1000       },       hide: {         effect: "explode",         duration: 1000       }     });      $("#select-button").click(function() {       $( "#dialog" ).dialog( "open" );     }); });  </script> 

-

//form  $main .= "     <form action='' method='post'>         <span class='forminput'>zoek:</span>         <input type='text' name='zoekproduct' />         <input id='select-button' type='submit' name='searchbtn' value='zoek!' />     </form>";  // end form 

-

// when used button     if(isset($_post['searchbtn']))     { // query     $statement = $connectionwebshop->prepare("     select          producten.productlink,         prod_omschrijving.producttitel             producten     inner join         prod_omschrijving      on         producten.idproduct=prod_omschrijving.idproduct     inner join         prod_categorie     on         producten.idproduct=prod_categorie.idproduct             (producten.productlink ?     or         prod_omschrijving.producttitel ?     or         producten.productcode ?)     ,         prod_categorie.idcategorieen != 8001     order         prod_omschrijving.producttitel     ");     $statement->error;     $zoekproductresult ='%'.$_post['zoekproduct'].'%';     $statement->bind_param('sss', $zoekproductresult, $zoekproductresult, $zoekproductresult);     $statement->execute(); $result = $statement->get_result(); //end query 

-

//create popup $main .='    <div id="dialog" title="resultaten selecteren" style="display: none">';             if(($result->num_rows)>=1)             {             $resultaten = 'found '.($result->num_rows).' products.<br/>';                  while ($row = $result->fetch_assoc())                 {                 $resultaten.= $row['producttitel'];                 $resultaten.='<br/>';                 }             }             else             {             $resultaten ='nothing found';             }         $main .= $resultaten;     $statement->close();     $main .='</div>';     } 

you need prevent default action of form if want popup show (otherwise page reload).

try this:

$("#select-button").click(function(e) {   e.preventdefault();   $("#dialog").dialog( "open" );    // post stuff   $.ajax({       url: 'form url here',       type: 'post',       data: 'zoekproduct=' + $('#zoekproduct').val(), // give zoekproduct input id       success: function (result) {           // success stuff here       }   }); }); 

example


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -