Jump to content

jquery ajax problem


RIRedinPA

Recommended Posts

I'm trying to do something seemingly pretty simple  - take a user selection from a select element and save it to a database...the select element gets written dynamically, like this:

 

...

$resultcode .= "</p><p class=\"livedate " . $bgcolor . "\">" . $duedate . "</p><p class=\"status\"><select class=\"changestatus\" name=\"status\" id=\"" . $id . "_	status\">";

						for($y=0; $y<count($statuslist); $y++) { 

							if ($status === $statuslist[$y]) { 
								$resultcode .= "<option value=\"" . strtolower($statuslist[$y]) . "\" selected>" . $statuslist[$y] . "</option>";
							} else { 
								$resultcode .= "<option value=\"" . strtolower($statuslist[$y]) . "\">" . $statuslist[$y] . "</option>";
							}
						}

				$resultcode .= "</select>

...

 

I then use javascript running jquery to get the item id, save that to a session, get the value selected and using AJAX send it to a php page to upload to a db...

 

Javascript:

 

//change status
			$('.changestatus').live('change', function() {

				//get and store id
				var thisid = getid(this);
				//get status value
				var thisstatus = $('.changestatus').val();
				//change active back to a checkbox
				$.ajax({
   						type: "POST",
   						url: "lib/updatestatus.php",
   						data: "thisstatus=" + thisstatus,
   						success: function(data) { 
   							$('#mainbox').html(data);
   							resizerows('tablerow');
					}
				});

			});
...

function getid(thisitem) { 
			//get id # from id attr and store in session
			var thisidstr = thisitem.id.split("_");
			var thisid = thisidstr[0];
			$.ajax({
   					type: "POST",
   					url: "lib/storeid.php",
   					data: "theid=" + thisid,
   					success: function(data){
     					//alert(data);
   					}
				});

				return thisid;
		}

 

problem is I keep getting this error message:

 

Query was empty Your request couldn't be procesed.

 

Even if I strip the updatestatus.php page down to just this

 

<?php session_start() ?>

 

I get the same error message. I can't find where it's failing. Any one have an idea?

Link to comment
Share on other sites

Does the php file run okay if you access it directly? Set default variables for the post variables so it'll run.

 

Trying running the script without the function that sets the id to the session.  Just grab the id and pass it to the php file.

If this works its something with your session code.

 

Try to keep simplifying the script until you find out what's breaking it.

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.