bob_the _builder Posted September 27, 2012 Share Posted September 27, 2012 Hey, im new to all the jquery stuff.. I cant get the function below to work proprely using serialize.. I guess I am way off track? $('#myForm').submit(function() { var data = $('#myForm').serialize(); $("#shop").html('<center> <img src="./loading.gif"></center>'); $.post("includes/cart-trans-process.php", data, function(response){ $("#shop").html(response); },'text'); }); echo '<form name="myForm" id="myForm">'; $sql = mysql_query("SELECT FROM trans ORDER BY firstname ASC"); while($row = mysql_fetch_array($sql)) { foreach($row as $key=>$value){ $$key = ValidateOutput($value); } echo '<tr> <p><a href="includes/cart-trans-delete.php?transid='.$transid.'" id="cart-trans-delete">x</a> | '.$firstname.' '.$lastname.' - <b>$'.$total.'</b></p> <p><input id="utotal" name="utotal[]" type="text" size="8"></p> <p><input type="hidden" id="method" name="method[]" value="'.$method.'"></p> <p><input type="hidden" id="firstname" name="firstname[]" value="'.$firstname.'"></p> <p><input type="hidden" id="lastname" name="lastname[]" value="'.$lastname.'"></p> <p><input type="hidden" id="email" name="email[]" value="'.$email.'"></p> <p><input type="hidden" id="total" name="total[]" value="'.$total.'"></p> <p><input type="hidden" id="transid" name="transid[]" value="'.$transid.'"></p> <input type="submit" id="myForm" value="Submit">'; } echo '</form>'; With the code above the entire page reloads.. Appears it doesnt link to the jquery function.. Thanks Quote Link to comment Share on other sites More sharing options...
gizmola Posted September 27, 2012 Share Posted September 27, 2012 To the script that you are posting to, what it is going to do is accept the $_POST data. I'm unclear on what you're trying to do and why, but I don't see any value in serializing a form and trying to send that to your serverside script. The serverside script should get the post values and then return back what you need to in terms of updating the client DOM with jquery. Quote Link to comment Share on other sites More sharing options...
bob_the _builder Posted September 28, 2012 Author Share Posted September 28, 2012 (edited) I am trying to capture the array of post variables on includes/cart-trans-process.php so process the request.. I used to use the following, but it only appearsd to work for single form variables apposed to an array of variables.. Im guesing that the use of id in the from locks it down to one variable not an array of variable.. ie <input id="utotal" name="utotal" type="text" size="8"> vers. <input id="utotal" name="utotal[]" type="text" size="8"> $("#cart-trans-process").live('click',function(){ var data = {utotal: $('#utotal').val(), total: $('#total').val(), method: $('#method').val(), firstname: $('#firstname').val(), lastname: $('#lastname').val(), email: $('#email').val(), transid: $('#transid').val(), }; $("#shop").html('<center><br /><br /><img src="./loading.gif"></center>'); $.post("includes/cart-trans-process.php", data, function(response){ $("#shop").html(response); },'text'); }); Edited September 28, 2012 by bob_the _builder Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.