Mootools Ajax表单响应

I'm trying to send a form with mootools and depending on the response from the php script do such or such thing. The thing is I fail to be able to use conditional statements inside of the onComplete part of the code.

I'm missing something really obvious probably, please help me :)

$('formName').addEvent('submit', function(e){
    e.stop();                      
    var req = new Request.HTML({
      url       : 'phpUrl.php',
      data      : $('formName'),
      update    : $('modify-me'),
      onComplete: function(){
            $('formName').reset();
            if($('modify-me').get('text') = "1"){
                alert("succeed");
                }else{
                alert("failure");
                }
            }  
    }).send();                    
  });

This was my lame attempt to use the php response in the code, but of course it didn't work. Needless to say I'm new to all this asynchronous client-server communication stuff, but I'm really intrigued by it.

You are assigning in your if statement (single =), not checking equality (==). Change the line

if($('modify-me').get('text') = "1")

to

if($('modify-me').get('text') == "1")

Sorry guys, maybe I'm late... I'm working on Mootools 1.2.4 for the client side and on PHP for the backend. This is the way I submit forms and get response from the server...

    $('myFormID').set('send', {
        noCache: true,
        onRequest: function(){
            // show some rotating loader gif...
        },
        onComplete: function(response) {
            // hide the loader gif...
            objJson = JSON.decode(response);
            if(objJson.success){
                // do your success stuff...
                alert(objJson.msg);
            } else {
                alert(objJson.msg);
            }
        },
        onFailure: function(){
            alert("Request Aborted.");
        }
    }).send();

In my case the form submit is triggered by a button, but could be whatever... let's look at the server side (I use PHP but any other language is good)

    if($somethingWentWrong){
    echo json_encode(array("success" => false, "msg" => "Check your form."));
} else {
    echo json_encode(array("success" => true, "msg" => "Data saved."));
}

after all the server-side checks and validations (and maybe an Update on a MySql batabase) I just return a Json array (that's whay I have a JSON.decode(response) on the client-side-earth) and then just check the "success" key to discover if the submitting succeded on the server-side-moon. I just add a small message that I display in an alert. Obviously I could use the JSON array to send back a lot more data to the client, but in this case is enough. Hope this helps and please let me know of better solutions.