jQuery Validate Ajax 验证
jQuery Validate Ajax 验证
<script type="text/javascript"> $(function() { $('#formCityLink').validate({ rules : { link : "required" }, messages : { link : "请输入链接" }, invalidHandler : function(){ console.log('in invalidehandler'); return false; }, submitHandler : function(){ console.log('in submithandler'); var url = 'city_link/create.do'; $.getJSON(url,{ link:$('#link').val() },function(data){ alert(data.res) }); return false; } }); $('#btnSaveLink').click(function(){ $('#formCityLink').submit(); }); });
之前在button的click事件中进行ajax请求,现在修改在validate中进行ajax请求;