getting data from jquery $.post

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
cali_dotcom
Forum Commoner
Posts: 49
Joined: Fri Aug 22, 2008 7:28 pm
Location: Rancho Cucamonga, CA

getting data from jquery $.post

Post by cali_dotcom »

i have a jquery link to post data to a php script

Code: Select all

<a href="ratepost.php" rel="nofollow"  class="vote_up_button" onclick="$.post(this.href, {postid: 44, vote: '1'}); return false;"  >
the problem i have is getting the values for postid and vote in the jquery ajax script and then in the php script

Code: Select all

$.click(function() {
		$.ajax({
			type: 'POST',
			url: $(this).attr('href'),
			data:  ({postid : data.postid, vote : data.vote}),
			dataType: 'json',
			success: function(data) {
does not work and the $_POST variable is empty in the php script.

Does anyone have any idea how i need to pass the variables in this script so as to populate the $_POST variable in the php script and not the $_GET?
sspatel82
Forum Newbie
Posts: 9
Joined: Tue Jul 19, 2011 10:52 am

Re: getting data from jquery $.post

Post by sspatel82 »

You can try using this one....
$.getJSON( 'http://<url>/index.php?variableName=?', function ( data ) {
alert ( data );
} );
Post Reply