Form is not submit using ajax.form submit on click li. Give me some solution
My js code is here
$(document).ready(function(){
$(\'#sortable li\').click(
You should provide your HTML too in your question, but as far as i can see, you have event
in event
callbacks with actually nothing to initiate the submit
event. So basically you should consider something like this :
$(document).ready(function(){
$('#sortable li').click(function() {
event.preventDefault();
var formdata = $("#frmgallery").serialize();
alert(formdata);
$.ajax({
type: "POST",
url: "gallery.php",
data: formdata,
success: function(){alert('success');}
});
});
});
Have you tried return false at the end of your submit function?
$("#frmgallery").submit(function(e) {
e.preventDefault();
var formdata = $(this).serialize();
alert(formdata);
$.ajax({
type: "POST",
url: "gallery.php",
data: formdata,
success: function(){alert('success');}
error: function(){alert('error');}
});
return false;
});
$('#sortable li').click(function() {
$("#frmgallery").submit();
});
Also post what you get from $.ajax
call
$("#frmgallery").ajaxForm({url: 'gallery.php', type: 'post'})
Have you tried return false at the end of your submit function?
$("#frmgallery").submit(function(e) {
e.preventDefault();
var formdata = $(this).serialize();
alert(formdata);
$.ajax({
type: "POST",
url: "gallery.php",
data: formdata,
success: function(){alert('success');}
error: function(){alert('error');}
});
return false;
});
$('#sortable li').click(function() {
$("#frmgallery").submit();
});
You can use the ajaxForm/ajaxSubmit functions from Ajax Form Plugin or the jQuery serialize function.
Example:
$("#frmgallery").ajaxForm({url: 'gallery.php', type: 'post'})
or
$("#frmgallery").ajaxSubmit({url: 'gallery.php', type: 'post'})
ajaxForm
will send when the submit button is pressed. ajaxSubmit
sends immediately.