javascript - Can I intercept form submit data to use with AJAX? -
i have django app shows list of items in selection item. when user changes selected item, use ajax insert form (using django's form , formset helpers) "content" section on page edit item's data.
what is, when user clicks "save" button on form, javascript function sends post data though form had been submitted, , uses ajax again reinject new data page.
i want maintain clean url @ times, return entry editing (hence ajax html replacement).
i prefer not have grab form fields , reconstruct string django forms recognize correctly.
is there way this? going whole thing wrong?
to grab whole form , send using ajax on submit (assuming jquery):
jquery('form').submit(function (event) { event.preventdefault(); var form = jquery(this); var data = form.serialize(); jquery.post(form.attr('action'), data, function(html) { ... }); });
Comments
Post a Comment