help with an ajax call

derrida
derrida used Ask the Experts™
on
hi
it is not the first time i`m doing this but something is not working. i use here and example so not to have too much code.

i have a form that i want to procccess via ajax. i use post.

i attach the code.

in firebug i see that i send and recieve what i need but when i want to alert the result i do not get any alert.

i`m sure i`m missing something/

best regards
function sendInfo(name,pass,article)

{

	

	$.post(

		"proccess.php",

		{

		"name" : name,


		"pass" : pass,
		
		"article" : article

		},

		function(result){

	
			if(result = true){


				//display errors;
				//alert(result);

   			 alert("great");

				}else{

				//display success
				alert("problem");

				}



		},'json'


	);

}


the form is within a jquery ui dialog, so i added the buttons like so:
buttons: {
			
			"update" : function(){
				var name = $("form#update input#name").val();
				var pass = $("form#update input#pass").val();
				var article = $("form#update #article").val();
				
				sendInfo(name,pass,article);
				
			},
			"Cancel" : function (){
				$(this).dialog("close");	
			}
		}


and the php side for now is the most simple it can be:
if(isset($_POST))
{
$n = $_POST['name'];
$p = $_POST['pass'];
$a = $_POST['article'];

	
	
	
	echo $n;
}else{
	echo 'no way';	
}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
leakim971Multitechnician
Top Expert 2014

Commented:
replace :if(result = true){
by : if(result!="no way"){
Commented:
Why did you mention the result datatype as "json" ?

I believe, you are just getting "true" as the response.

Remove the result datatype 'json' and try.

Also notice, you are using "result = true" instead it should be either if(result == 'true') or if(result)

You can just try alert(result), before if and see what result you get.

Author

Commented:
i cannot beleave i did not noticed

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial