Jump to content

updating database record using Ajax


svgmx5

Recommended Posts

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!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.