I'm developing a website(just for fun) and have been using mostly js/jquery to build the website while communicating with the server with $.post for logging in, sending textareas that the user submitted, etc.
Is there any downfall to this? Should I be doing this another way开发者_如何转开发?
as always "it depends" on what you're doing...
If this site is just "for fun", then no, no problem.
If you're putting it on the internet, then you want to make sure your user actions (especially login and such) are done over SSL (which affects how you serve your JS files).
If you want any old user to use it (i.e. folks other than you and your immediate friends), then you need to provide a fallback method (traditional forms) so that if they're on a device that doesn't play w/ javascript nicely, they can still use the app.
As long as your website is fully functional without JavaScript, I see no problem in this. If you go even further and use jQuery for the navigation, be aware that Search robots will not be able to index your page and (if you aren't careful and use anchors) you visitors will have a hard time using the back/forward buttons in their browsers.
A POST
via JQuery is equal to a POST
via HTML (form submit) in every way except one: HTML's is synchronous, JQuery's is asynchronous. Having this in mind, there's no downfall in doing it other than having to refresh certain parts of the page on the fly (once the user logs in) which can be tedious (E.g: having to change dynamically the login box with a "user panel") and therefore leads a lot of developers to just use a HTML POST
.
精彩评论