Reputation: 73
Here's what I am trying to do. I have a page that uses CSS to show/hide different content divs. One of the divs is a form that submits a record to a database. After clicking "Submit" I do not want to redirect back to the default page content, which is what would happen by calling the script in the form action and using a simple response.redirect at the end of the ASP script. Instead I want to pass the form info off to the ASP script in an iframe (or some other way) and then just clear the form. This way the user can go ahead and enter another incident in the form without having to click an "Add Incident" button again in the navigation to show the hidden form div (which is how it loads the default page if I were to redirect back).
I see a couple of ways to handle this: - As I mentioned above, the form data is sent off to the ASP in an iframe or some such thing. - I call the ASP script as normal, but when doing the response.redirect to default.asp, somehow also tell the page to display the form div instead of the default content
In either case, I'm not sure exactly how I would do this. Any help?
Upvotes: 1
Views: 163
Reputation: 1572
If I understood you correctly, what you want to do is not to post to iframe, but to use ajax with jquery. Rough outline would be something like this:
$(function () {
$('form').submit(function (e) {
e.preventDefault();
$.ajax({
type: 'POST',
url: 'submit.asp',
data: 'input1=' + escape($.trim($('#input1').val())),
dataType: 'html'
}).done(function (data) {
if (data) {
// clear the form
}
});
});
});
Upvotes: 1
Reputation: 527
You should use Ajax to handle this scenario. With Javascript you can collect the form data and then make an ajax call when the user clicks your submit button.
Upvotes: -1