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 03-02-2011, 04:29 PM   PM User | #1
DKY
New Coder

 
Join Date: Jan 2009
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
DKY is an unknown quantity at this point
php/jquery validate and then update(mysql)

I'm really struggling here trying to get some validation in place for my ajax. I am using jQuery with php right now to update a mysql table. I'm currently trying to figure out how to put a warning in a popup alert that says that I can't have a frompdc value the same as a topdc value. Today I have jQuery that says:

Code:
$("#frompdc<?php echo $JavaCnt;?>").change(function(){
	var id     = $('#id<?php echo $JavaCnt;?>').attr('value');
	var frompdc     = $('#frompdc<?php echo $JavaCnt;?>').attr('value');
	var topdc     = $('#topdc<?php echo $JavaCnt;?>').attr('value');
	//alert("firm=frompdc&id="+ id + "&frompdc=" + frompdc + "&topdc=" + topdc) 	
		$.ajax({
			type: "POST",
			url: "AJ_Update.php",
			data: "firm=frompdc&id="+ id + "&frompdc=" + frompdc + "&topdc=" + topdc
		});		
	return false;
	}
	);
Which seems to work out beautifully with this php on another page:

Code:
IF($_POST['frompdc'] <> $_POST['topdc'])
		{
			mysql_query("UPDATE TBLTRANSFERS SET FROMPDC = ".$_POST['frompdc'].", MOD_TS = '". $timenow ."' WHERE ID = ".$_POST['id']); 
		}
I changed my php to say
Code:
		IF($_POST['frompdc'] <> $_POST['topdc'])
		{
			mysql_query("UPDATE TBLTRANSFERS SET FROMPDC = ".$_POST['frompdc'].", MOD_TS = '". $timenow ."' WHERE ID = ".$_POST['id']); 
		}ELSE{
			ECHO "Can't be the same";
		}
but can't figure out how to get that echo to go back to my jQuery and display an alert box with that text. Help?

Last edited by DKY; 03-02-2011 at 09:14 PM..
DKY 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 07:10 PM.


Advertisement
Log in to turn off these ads.