coolboymark
coolboymark

Reputation: 203

how to post form with yui3

When i use yui3`s io-form module to post a form, i found the field value that server reseived is null... Any help is welcome.

<form  name='testajax' id="testajax1" >
  <input type="text" name="test1"  id="test1" ></input>
  <input type="text" name="test2"  >
  <input type="text" name="test3" id="result" >
  <input type="submit" value="submit" id="submit">
</form>


Y.io('/ajax/test',{
        method:'POST',
    form: {
            id:Y.one('#testajax1'),
            useDisabled: true,

          },
        on:{
                complete:function(id,response){
                                 Y.log(Y.one('#test1').get('value'));
                         },
                start:function(id,response){
                                 Y.log(Y.one('#test1').value);
                         }
        }
});

Upvotes: 1

Views: 2595

Answers (1)

Brian J. Miller
Brian J. Miller

Reputation: 2274

You are passing a Y.Node to form.id and the docs indicate that it takes either a string or a "formObject" which I'm assuming means a "form element". I don't believe a Y.Node is a valid (which is an unfortunate API choice if true). Try switching your code to:

form: {
    id: "#testajax1"
}

http://yuilibrary.com/yui/docs/io/#serializing-html-form-as-data

Upvotes: 1

Related Questions