svgmx5 Posted August 4, 2011 Share Posted August 4, 2011 I'm working on this script that will allow a user to update the order of images. Basically i have a database that holds images the user uploads, now i want to let the user change the order of the images (1, 2, 3 etc). On the database i have a field named "order" which is where it will update based on what the users inputs. Now what i'm trying to do is, to do this using ajax. I'm trying to have the script fire up as soon as the user types in a number. so i have a text input field in which as soon as the user types in a number say "1" then the script will fire up and update that record "order" field to "1". Below is the script i'm working now, however i'm not sure what's wrong and why it isn't working. function orderUpdate(rowID, inputString) { var query = "queryString="+rowID+"&string="+inputString+"" $.post("../sripts/php/picOrderUpdate.php", query , function(data){ <---- this is line 130 }); } I haven't set a way to let the user know that it has been updated, but i do plan on doing it. i just want to test this first and make sure it works. Below is just a snippet on how the table row that holds each db record row is displayed <tr> <td width="24"><input type="text" value="" size="2" maxlength="2" onkeyup="orderUpdate('<?php echo $pointImages['id']; ?>', this.value)" /></td> <td width="260">image is displayed on this column</td> </tr> the "$pointImages['id']" is the row id the database returns and "this.value" is pretty much what the user inputs. Also, if it helps while using google Chrome's Developer Tools the following error displays : "uncaught ReferenceErrror: $ is not defined" this is on line 130 of the script I hope someone can help me figure this out thanks! Quote Link to comment https://forums.phpfreaks.com/topic/243766-updating-database-record-using-ajax/ Share on other sites More sharing options...
JasonLewis Posted August 8, 2011 Share Posted August 8, 2011 I'm assuming you've loaded in the jQuery library or whichever framework you're using prior to calling the $.post() function? Quote Link to comment https://forums.phpfreaks.com/topic/243766-updating-database-record-using-ajax/#findComment-1254366 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.