ajax submit the form, including the jump into the pit!

Originally this morning wrote a js execution context of an understanding. But more than half the time out to write something, shut the computer got nothing.

Let us get to the point

ajax submit the form, very simple, native js code is too complicated, we have to go write jq.

Create html file written content.

css styles I just wrote about.

After writing is so

Style you just happy on the line, began to write js code. (Here I say that I am here with a json:. Server is not fake data can take a look, I wrote how to build json:. Server in question can leave a message)

We first data to render it.

This time we will be able to see the data.

And finally to the theme.

Which are explained in the diagram, I think put the figure said here than in say, a good understanding more.

Then we completed submission form, this time, you will find that you submit, no error, no response. (Want to know the results, jump to the last!)

Then I tried it, just click, indicates that the transfer was successful, but the only option in the defaults.

Then I have tried it as just the name, but also magical pass success. But the other is empty.

I tried a lot behind, are a result, not all incoming.

Here, I try to print a value in which the request was successful, but not the line.

How does this solve it, try for a long time, but also a lot of Baidu, others say that is using the button, do not use submit. I think there is no problem ah.

Then I think, the value of his biography will be free, it is not it can not get the value, so I try to put the request to write off. Then click try, ah, did not get.

The thought here will refresh button click, so, right button changed to div. Try a bit Oh. Finally worth it.

Then I put the request in return, it can be had. Details of the problem here, I do not know why. I understand that I preach is worth the way, can not be refreshed.

The above does not work, so long as the change

 

Guess you like

Origin www.cnblogs.com/chenyudi/p/11257332.html