I have been trying to update my database by passing data from a form submit via the jquery ajax features, more so using a form plug-in.
I am able to grab my data, and send it to my process.php to do a sql update query.
from there i'm trying to figure out how to refresh the content of my div dynamically once the form is submitted.
here is my jquery code:
// AJAX response for FORM submission //
// prepare the form when the DOM is ready
$(document).ready(function() {
var options = {
url: 'process.php',
type: 'post',
//dataType: 'json',
target: '#last_five_sellers',
//beforeSubmit: showRequest,
success: success
};
// bind to the form's submit event
$('#form').submit(function() {
// inleft event callbacks 'this' is the DOM element so we first
// wrap it in a jQuery object and then invoke ajaxSubmit
$(this).ajaxSubmit(options);
// !!! Important !!!
// always return false to prevent standard browser submit and page navigation
return false;
});
function success(data) {
$("form#form").hide();
$(".success").fadeIn();
//$("#last_five_sellers").empty();
//$("#last_five_sellers").fadeOut();
//$("#last_five_sellers").replaceWith(data);
}
});
the fadeIn works, but the empty(), fadeOut(), and replaceWith() doesn't
if you notice atop the script there is a target parameter, where the plug-in loads the new form data into
Question
saiya
Hello,
I have been trying to update my database by passing data from a form submit via the jquery ajax features, more so using a form plug-in.
I am able to grab my data, and send it to my process.php to do a sql update query.
from there i'm trying to figure out how to refresh the content of my div dynamically once the form is submitted.
here is my jquery code:
// AJAX response for FORM submission // // prepare the form when the DOM is ready $(document).ready(function() { var options = { url: 'process.php', type: 'post', //dataType: 'json', target: '#last_five_sellers', //beforeSubmit: showRequest, success: success }; // bind to the form's submit event $('#form').submit(function() { // inleft event callbacks 'this' is the DOM element so we first // wrap it in a jQuery object and then invoke ajaxSubmit $(this).ajaxSubmit(options); // !!! Important !!! // always return false to prevent standard browser submit and page navigation return false; }); function success(data) { $("form#form").hide(); $(".success").fadeIn(); //$("#last_five_sellers").empty(); //$("#last_five_sellers").fadeOut(); //$("#last_five_sellers").replaceWith(data); } });the fadeIn works, but the empty(), fadeOut(), and replaceWith() doesn't
if you notice atop the script there is a target parameter, where the plug-in loads the new form data into
Link to comment
Share on other sites
4 answers to this question
Recommended Posts