Page 1 of 1

getting data from jquery $.post

Posted: Tue Jul 19, 2011 9:40 am
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?

Re: getting data from jquery $.post

Posted: Tue Jul 19, 2011 11:25 am
by sspatel82
You can try using this one....
$.getJSON( 'http://<url>/index.php?variableName=?', function ( data ) {
alert ( data );
} );