php - Jquery Ajax Post failed after Serialize [jquery / javascript] -


I have a search for other posts but no answer does not work for me. I have a cross-domain problem so cross- Domain problem is not a problem here.

My javascript / jquery code:

  $ (document) .ready (function () {$ ("button"). (Function (event) {event.preventDefault (); $ .post ("http://mydomain.com/api/user/register", / / ​​{email: "donald@duck.com", // name : "Duckburg" //} $ ("Login Form"). Serialize (), Function (data, position) {$ ("#transfertravel"). Text ("data:" + data + "/ nStatus:" + status) ;});});});  

My HTML code:

  & lt ;! - Page 3 [userlogin] - & gt; & Lt; Div data-role = "page" id = "userlogin" & gt; & Lt; Div role = "main" square = "ui-content" & gt; & Lt; Div & gt; & Lt; Form action = "/" id = "loginForm" & gt; & Lt; Label = "email" & gt; Email & lt; / Labels & gt; & Lt; Input type = "text" name = "email" id = "email" value = "" & gt; & Lt; Label = "password" & gt; Password & lt; / Label & gt; & Lt; Input type = "text" name = "password" id = "password" value = "" & gt; & Lt; Button ID = "Login Button" /> Submit & lt; / Button & gt; & Lt; / Form & gt; & Lt; A href = "welcome" class = "ui-btn ui-corner-all ui-icon-back-black" data-transition = "flow" data-direction = "reverse" & gt; Back to the main screen & lt; / A & gt; & Lt; / Div & gt; & Lt; Div id = "loginresult" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt ;! - / content - & gt; & Lt; / Div & gt; & Lt ;! - Page 3 End - & gt;  

My PHP code:

  $ email = $ _POST ["email"]; $ File = fopen ("capture.txt", "w"); FILIT ($ file, $ email. "\ N"); Fclose ($ file); Email per email;  

The above Ajax call will use the object {object} commented as a data input on the post if successfully posted.

But if I use serial () as data input, Ajax call will fail. The server side also does not get the value because it is not written in the text file.

I've read the document many times and as well as other tutorials I can get through Google. But it just does not work.

Edit the data portion:

  $ ("# LoginFormat "). Serialize (),  

Comments