Welcome Guest, Not a member yet? Register   Sign In
Help with adding a jquery alert box after form is correctly submitted
#11

[eluser]LuckyFella73[/eluser]
I allready wrote that in the comments. When your callback
function returns something then your js function gets the data
as "data" array. In my example your array has a key "message".
So you can access the returned values via writing data.message
inside the function
Code:
function(data){

Did you try to implement the code and do you get the alert
with a message from your calback function when submitting the
form?

I didn't answer one of your questions:
Quote:1. What’s the json_encode function for?

In your js function you set how the data has to be encoded when
communicating with view and callback function. The js has to know
in what kind of format the data will be returned. In my example
we defined "json" as the format. You could change that - see jquery
user guide. Json is just very simple to use. That's why you have to
json encode the data in your callback function before returning it.
If you have PHP4 installed you can do it like in my example, if you
have PHP5 installed you can use the PHP function json_encode() which
is not available in PHP4. I think there are some classes outside which
emulate the json_encode() function and make it easier to format the
data json encoded (what I did manually in my example). Here are more
informations about json:
http://www.json.org/


Messages In This Thread
Help with adding a jquery alert box after form is correctly submitted - by El Forum - 05-12-2010, 02:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB