Tuesday, 15 May 2012

javascript - image button - no page change -



javascript - image button - no page change -

i'm trying phone call php file without refreshing page. code executes php file, value toid not beingness passed along. if manually query page works fine. other issue im having button needs image path src="{root_path}mchat/quote.gif"

<form id="myform" method="post" class="form_statusinput"> <input type="hidden" name="toid" id="toid" value="<?php echo {mchatrow.mchat_username}; ?>"> <div id="button_block"> <input type="submit" id="button" value="enter"> </div> </form> <script> $(document).ready(function(){ $("form#myform").submit(function(event) { event.preventdefault(); var toid = $("#toid").val(); $.ajax({ type: "post", url: "randomquote.php", data: "toid=" + toid, }); }); }); </script>

any ideas?

when "if manually query page works fine", mean hitting endpoint straight like

http://yoursite.com/randomquote.php?toid=239439

have tried sending info object (like this):

$.ajax({ type: "post", url: "randomquote.php", data: { toid: toid } });

that may trick.

javascript html

No comments:

Post a Comment