开发者

inpage ajax forms

开发者 https://www.devze.com 2023-02-14 04:58 出处:网络
I am currently creating a application and would like to add a AJAX feature, but i cant seem to find any examples of what i want!

I am currently creating a application and would like to add a AJAX feature, but i cant seem to find any examples of what i want!

Im tryin to keep everything on one page.

So for example, i already have a automatically generated list of products down the left of my page, which are displayed via JQUERY-->servlet.

now if a user clicks on a product it directs them to a html page with a form that submits to the servlet (i haven't coded this, but i know how too).

But what i want is, when a user click the product, the form is loaded into a designated div on the page, in which a user can fill it in and submit to the servlet without leaving the page.

Would i be better of coding a JSP page and thenpulling that into the main JSP page? or creating a form in jquery?

Could anyone point me in the right开发者_如何学C direction?


Have a look at the jQuery-ui dialog, the validation plugin and the form plugin. These should be all you need to produce great dialog based ajax forms with validation.

If you need to upload files, I have found that the uploadify plugin is great for submitting files with form data.


With the future in mind I would have the form be its own JSP and pull it in via jQuery, it will make it easier to edit the form and will be easier to find for the next developer. Maintaining forms built in jQuery (or JS in general) is not fun.


I think what you're describing can be accomplished using a modal dialog type of jQuery plug-in. There are a number of them out there, but you can look at jQuery UI's dialog widget (link) to see a basic one.

A better one is simplemodal from Eric Martin. You can display your form in the modal and then have the user submit the modal to your back-end server.

I deal more with .NET programming, but use these plug-ins for modal forms and submitting them to back-end services. I usually extract the form into a separate HTML page and then load the form in dynamically. It keeps my JavaScript free from markup and also allows me to make changes to my modal template without really digging into my JavaScript files.

0

精彩评论

暂无评论...
验证码 换一张
取 消