Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-08-2012, 11:26 PM   PM User | #1
zingzing45
New Coder

 
Join Date: Jun 2012
Posts: 57
Thanks: 13
Thanked 0 Times in 0 Posts
zingzing45 is an unknown quantity at this point
Exclamation How to $_POST Ajax data?

Hi, I've been working on a site that sends data with jQuery Ajax to a url: profile.php

I'm having some trouble retrieving this data on the PHP page, profile.php



Here is profile.php (the part that is not working)




PHP Code:
$previouschoice $_POST['data'];

if (
$previouschoice == 'blueBGhas: "yes"')

{

$superSTRsql "UPDATE Customize SET BlueBGhas='yes' WHERE Username = '$username'";

$superSTRsql1 "UPDATE Customize SET YellowBGhas='no' WHERE Username = '$username'";

$superSTRsql2 "UPDATE Customize SET GreenBGhas='no' WHERE Username = '$username'";

$superSTRsql3 "UPDATE Customize SET RedBGhas='no' WHERE Username = '$username'";

$superSTRsql4 "UPDATE Customize SET PurpleBGhas='no' WHERE Username = '$username'";

$superSTRsql5 "UPDATE Customize SET BlackBGhas='no' WHERE Username = '$username'";

mysql_query($superSTRsql$connection);

mysql_query($superSTRsql1$connection);

mysql_query($superSTRsql2$connection);

mysql_query($superSTRsql3$connection);

mysql_query($superSTRsql4$connection);

mysql_query($superSTRsql5$connection);

}

else if (
$previouschoice == 'greenBGhas: "yes"')

{

$superSTRsql "UPDATE Customize SET BlueBGhas='no' WHERE Username = '$username'";

$superSTRsql1 "UPDATE Customize SET YellowBGhas='no' WHERE Username = '$username'";

$superSTRsql2 "UPDATE Customize SET GreenBGhas='yes' WHERE Username = '$username'";

$superSTRsql3 "UPDATE Customize SET RedBGhas='no' WHERE Username = '$username'";

$superSTRsql4 "UPDATE Customize SET PurpleBGhas='no' WHERE Username = '$username'";

$superSTRsql5 "UPDATE Customize SET BlackBGhas='no' WHERE Username = '$username'";

mysql_query($superSTRsql$connection);

mysql_query($superSTRsql1$connection);

mysql_query($superSTRsql2$connection);

mysql_query($superSTRsql3$connection);

mysql_query($superSTRsql4$connection);

mysql_query($superSTRsql5$connection);

}



//Another few lines later...





if ($blueBGhas == 'yes')

{

echo 
'<style>body { background: blue; }</style>';

}

else if (
$greenBGhas == 'yes')

{

echo 
'<style>body { background: green; }</style>';






Just to make sure, here is my jQuery Ajax code:




Code:
//AJAX STUFF

		$(document).ready(function()
		
		{
		
		$('#bluebgradio').click(function()
		
		{
		
		$.ajax(
		
		{
		
		type: "POST",
		
		url: "profile.php",
		
		data: {blueBGhas: "yes"}

		});

		});

		$('#greenbgradio').click(function()
		
		{
		
		$.ajax(
		
		{
		
		type: "POST",
		
		url: "profile.php",
		
		data: {greenBGhas: "yes"}

		});

		});

		});
zingzing45 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:41 AM.


Advertisement
Log in to turn off these ads.