[jQuery] Re: How to handle responses from PHP with $.ajax()

2009-01-22 Thread Agile Consulting
Its a nice group

[jQuery] Re: How to handle responses from PHP with $.ajax()

2009-01-19 Thread Agile Consulting
What is difference between Oracle and SQL Server

[jQuery] Re: How to handle responses from PHP with $.ajax()

2009-01-04 Thread rob303
I found the problem. I was missing the dataType option: $(document).ready(function(){ $("form#submit").submit(function() { var email = $('#email').attr('value'); $.ajax({ type: "POST", url: "ajax.php", data: "email="+ email,

[jQuery] Re: How to handle responses from PHP with $.ajax()

2009-01-04 Thread rob303
After a little more twiddling ... This works: $(document).ready(function(){ $("form#submit").submit(function() { var email = $('#email').attr('value'); $.ajax({ type: "POST", url: "ajax.php", data: "email="+ email, succes

[jQuery] Re: How to handle responses from PHP with $.ajax()

2009-01-04 Thread rob303
Hi again, I tried that but got the same results. if(res.result == '1') { $('form#submit').hide(); $('div.success').fadeIn('medium'); } else { $('div.error').show(); } if(res.result == 1) { $('form#submit').hide(); $('div.success').fadeIn('medium'); } else { $('div.error').show(); }

[jQuery] Re: How to handle responses from PHP with $.ajax()

2009-01-04 Thread donb
On another thread, someone pointed out to me that json_encode was supposed to 'know' if the data values were numeric or string and only quote the latter. That was not my experience, and perhaps not yours, either. Try '1' as the value you compare to instead of 1. On Jan 4, 1:05 pm, rob303 wrot

[jQuery] Re: How to handle responses from PHP with $.ajax()

2009-01-04 Thread rob303
Interestingly, in the Firebug console I'm seeing the correct responses: {"result":1} or {"result":0} How can I access these inside my $.ajax() call? Many thanks again for all the help! Rob. On Jan 4, 5:57 pm, rob303 wrote: > Yes, the missing semicolons are an error in the post. I tried to

[jQuery] Re: How to handle responses from PHP with $.ajax()

2009-01-04 Thread rob303
Yes, the missing semicolons are an error in the post. I tried to echo the json_encode() call but I still can't get it to work. If I leave the email input blank no email is sent. If I enter a string the email is sent. The 'div.error' is always displayed regardless what's posted. Here's my full cod

[jQuery] Re: How to handle responses from PHP with $.ajax()

2009-01-04 Thread donb
You must 'echo' the JSON output. Also you indicate periods ending code lines, instead of semicolons but perhaps that's just an error in your post, not the actual code? On Jan 4, 10:38 am, rob303 wrote: > Hi, > > Many thanks for the help.  I had a go at implementing what you > suggested but I'm

[jQuery] Re: How to handle responses from PHP with $.ajax()

2009-01-04 Thread rob303
Hi, Many thanks for the help. I had a go at implementing what you suggested but I'm clearly still missing something. Here is my $.ajax() call: -- $(document).ready(function(){ $("form#submit").submit(function() { var email = $('#email').attr('value');

[jQuery] Re: How to handle responses from PHP with $.ajax()

2009-01-04 Thread donb
Return a JSON object. Construct a PHP array such as $json_data = array('result' => 0, 'error' => 'This is an error'). End your PHP script with json_encode ($json_data). Then you can reference del.result and del.error (I'm referring to your definition of the' success' function from your sample c