954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Post jQuery variable

Hi Guys,

Can't seem to get my head around this one. I need to send a bunch of variables to php so that i can store the values in a database, but i just can't figure out a way to do that. Pls help. here's a little code

$( "#droppable2" ).droppable({
	activeClass: "ui-state-hover",
	hoverClass: "ui-state-active",
	accept: "#draggable3",
	drop: function( event, ui ) {
				
		var jdc = $(this).attr("id"); //I need to post this variable
		$( this )
			.addClass( "ui-state-highlight" )
			var x = ui.helper.clone();   
			x.appendTo('body');
					
			var jdi = $("img").attr("id");//I need to post this variable
					
			$(this).droppable( 'disable' );
					
			x.append("<span>x</span>")
			$("span").click(function (){
				$("#droppable2").droppable('enable');
				x.remove();
			})
	}
});


I can post more code if needed. I really need this.

Thanks in advance

newboi
Newbie Poster
7 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

What doesn't work? Take a look at $.ajax and $.post.

twiss
Veteran Poster
1,005 posts since Apr 2010
Reputation Points: 177
Solved Threads: 101
 

Thanks for the response twiss.

Perhaps my need was not stated correctly. What I want to do is to save or be able to access those variables later on in the script, but because they are local variables... I am having problems calling them later on in the script.

In a nutshell, I want to be able to call up local variables from other three identical functions and send them all together later on. If that makes sense.

newboi
Newbie Poster
7 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

If the need for storing is only temporal, then cookies could help with this. Otherwise you could use AJAX to store (and retrieve) those values more permanently.

http://www.w3schools.com/xml/xml_http.asp

F-3000
Newbie Poster
8 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: