我的表格
<tfoot>
<form method="post" action="kategoriler.php">
<tr>
<th>Select</th>
<th><input type="text" name="id" id="id" class="form-control" style="width:80px;" placeholder="#"></th>
<th>Image</th>
<th><input type="text" name="name" id="name" class="form-control" style="width:120px;" placeholder="Name"></th>
<th>Order</th>
<th><input type="text" name="Visibility" id="Visibility" class="form-control" style="width:120px;" placeholder="Visibility"></th>
<th>Date</th>
<th>Edit</th>
</tr>
</form>
</tfoot>
我想用json和onkeyup函数发布这些值,我该如何发送这个表单值?
答案 0 :(得分:1)
使用jQuery ajax:
$(document).keydown(function(e) {
$.ajax({
type: "POST",
dataType: "json",
url: "kategoriler.php",
data: {name: $('#name').val() //ETC...},
success: function (html) {
alert('ok');
}
});
});
答案 1 :(得分:1)
这可以在表单
中的所有输入类型上添加keyup函数$('form input:text').keyup(function(){
var data = $("form").serialize();
$.ajax({
url: 'kategoriler.php',
data: data,
dataType:'json',
type:'POST',
async:false,
success: function(data) {
alert('submitted');
}
});
如果要在特定输入类型上添加keyup,则只需替换
$('form input:text').keyup(function(){
使用
$('#id').keyup(function(){
答案 2 :(得分:0)
//trigger form submit
$(document).keyup(function(){
$("form").submit();
});
//Do what you whant with your form
$("form").submit(function(){
//Do something eg. ajax call
$.ajax({
type: "POST",
dataType: "json",
url: "kategoriler.php",
data: {name: $('#name').val() //ETC...},
success: function (html) {
alert('ok');
}
});
});