jQuery.ValidateをAJAXのPOST送信で使う
- 2012年07月25日
- WEB開発
$(function(){
$('#dialog').dialog({
autoOpen: false,
width: 800,
height: 700,
title: '送信フォーム',
modal:true,
resizable:true,
buttons: {
"送信": function() {
if(confirm("送信してよろしいですか?")){
if ($("#FRM").validate().form() == true) {
var params = $("#FRM").serialize();
$.ajax({
url: "http://www.hoge.com/post.php",
type: "post",
data: params,
async: false,
cache: false,
error: function(a,b){
alert(b);
},
success: function(response) {
}
});
$(this).dialog("close");
}
}
}
}
}
}
12行めの書き方が、普通のmethod=”post”の時とは違うので注意されたい。
jQuery.UI のdialogと jQueryのserializeと AJAXのPOST送信と jQuery.validateの併用方法。
よく使う黄金パターンなので、自分メモ。
検索
© 2025 Copyright OKESYS. All rights reserverd.