表单提交使用jQuery阿贾克斯 [英] Form submission using jQuery ajax
本文介绍了表单提交使用jQuery阿贾克斯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
表没有提交使用ajax.form提交关于点击华里。给我一些解决方案
Form is not submit using ajax.form submit on click li. Give me some solution
我的js code是这里
My js code is here
$(document).ready(function(){
$('#sortable li').click(function() {
$("#frmgallery").submit(function(event) {
event.preventDefault();
var formdata = $(this).serialize();
alert(formdata);
$.ajax({
type: "POST",
url: "gallery.php",
data: formdata,
success: function(){alert('success');}
});
});
});
HTML是这里
HTML is here
<form method="post" enctype="multipart/form-data" id="frmgallery" name="gallery" action="<?php get_template_directory();?>admin.php?page=gallery/gallery.php">
<ul id="sortable">
Query
<li class="ui-state-default" name='liindex' id="<?php echo $row['glryRecordId'];?>" >
<span style="display:none"><?php echo $row['glryRecordId'];?></span>
<img class='thumbnail' alt='' src='<?php echo get_site_url();?>/wp-content/themes/townsley/upload/<?php echo $row['glryName']; ?>' width='80' height='60'
style="border: 1px solid #D3D3D3;padding:2px;"/><input type="hidden" value="<?php echo $row['glryRecordId'];?>" name="recordId[]" />
<a href="<?php get_template_directory();?>admin.php?page=gallery/gallery.php&delid=<?php echo $row['glryRecordId'];?>" style="display:block;text-align:center" title="DELETE this image from the record" class="arial-red">Remove</a>
</li>
</ul>
</form>
请帮我 谢谢
AJAX的jQuery JavaScript的
ajax jquery javascript
推荐答案
您应该为您的HTML过你的问题,但据我所看到的,你有事件
在事件
回调有其实也没什么启动提交
事件。所以基本上你应该考虑是这样的:
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');}
});
});
});
这篇关于表单提交使用jQuery阿贾克斯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文