Processing Jquery Post with PHP -
Processing Jquery Post with PHP -
i've been @ hours, , i'm @ finish loss.... i've tried can problem i'm not familiar jquery, first time i've ever used it.... basically, i'm attempting pass form info php script, , homecoming variable contain source code of webpage.
here jquery:
$("button").click(function(){ hi = $("#domain").serialize(); var page; $.ajax({ type: "post", url: "webcrawler.php", data: hi, //datatype: "text", success: function(data){ page = data; document.write(page); } }); });
here html references:
<div id="contact_form"> <form name="contact" action=""> <fieldset> <label for="domain" id="domain_label">name</label> <input type="text" name="domain" id="domain" size="30" value="" class="text-input" /> <input type="submit" name="submit" class="button" id="submit_btn" value="send" /> </fieldset> </form> </div>
here php process it: $search = $_post["domain"]; if(!$fp = fopen($search,"r" )) { homecoming false; } fopen($search,"r" ); $data = ""; while(!feof($fp)) { $data .= fgets($fp, 1024); } fclose($fp); homecoming $data; ?>
i think variable $search blank, because i'm not sending correctly jquery or receiving correctly php? thanks!
see have several things:
$("form[id='contact_form']").submit(function (e) {//<---instead click submit form e.preventdefault(); //<----------------you have stop submit ajax info = $(this).serialize(); //<----------$(this) form here serialize var page; $.ajax({ type: "post", url: "webcrawler.php", data: data, success: function (data) { page = data; document.write(page); } }); });
so in comments:
submit form
instead button click
stop form submission
otherwise page refreshed. $(this).serialize()
serializing form here because here $(this)
form itself. php jquery forms
Comments
Post a Comment