javascript - JQuery ajax serialized input text field is empty on server side -
I have some radios field and an input text type field on my form:
& Lt; Input name = "cbPerson" type = "radio" value = "1" checked & gt; Person1 & lt; Input name = "cbPerson" type = "radio" value = "2" /> Person2 & lt; Input name = "txtName" type = "text" / & gt; I am serializing my form like this:
$ Ajax ({type: 'post', url: 'form-1-proc.php', data: $ ('form'). Serialize (), success: function (data) {warning (data);}, error: Function () {warning ('error';}}); And I'm getting data on the server side ( form-1-proc.php ) : $ person = $ _POST ['cbPerson']; $ name = $ _POST ['txtName']; variable $ person has the expected value, but the variable $ name never brings a value and it is always "0". This page is an al-Jumla operated website on BTW The page has been worked as a page, the page itself is at the root of the site, so there is no mess with Joomla routing and stuff.
Can you please tell me how to get data from the input text field Can I do? Both have a name attribute and it holds a value on the client if I generate a warning with the value of the function of the function or the JavaScript via the console. < p> Dhan Thanks.
I am not able to repeat this issue.
test.php & lt ?? Php if (count ($ _ POST)) {$ person = $ _POST ['cbPerson']; $ Name = $ _POST ['txtName']; Exit ("person = $ person = name = $ name"); }? & Gt; & Lt; Script type = "text / javascript" src = "http://code.jquery.com/jquery-1.11.0.min.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; Function Test () {$. AZ ({type: 'post', url: 'test.php', data: $ ('form'). Serialize (), success: function (data) {warning (data);}, error: function () { Warning ('Error');}}); } & Lt; / Script & gt; & Lt; Form & gt; & Lt; Input name = "cbPerson" type = "radio" value = "1" checked & gt; Person1 & lt; Input name = "cbPerson" type = "radio" value = "2" /> person 2 & lt; Input name = "txtName" type = "text" / & gt; & Lt; Input type = "button" onclick = "test ();" Value = "test" & gt; & Lt; / Form & gt;
Comments
Post a Comment