html表单提交为on,html5表单在使用jQuery .on()方法进行按钮 - 点击事件而不是表单 - 提交事件时无需验证。为什么?...

$j(document).on("click", "#client_entry_add", function(event){ ajax_submit();});

虽然下面的代码可以让HTML5验证发生,但在Opera浏览器也不起作用,并没有得到验证提交的(在其他浏览器(检查用于Firefox /铬)验证发生)

$j(document).on("submit", "#client_entry_form", function(event){ ajax_submit();});

我的问题是

为什么当我们绑定处理程序,以点击的事件,而不是这种情况提交?

为什么即使不在opera中提交事件类型?

谢谢。

============================================== ====================================

形式和JavaScript代码

function ajax_CALL(OBJECT , URL , PARAMS , TARGET)

{//alert ('in for -> ' + URL);

if (typeof OBJECT != 'undefined' && OBJECT != null)

{

if($j('#'+OBJECT).length){OBJECT = $j('#'+OBJECT);}

else

if( $j('.'+OBJECT).length){OBJECT = $j('.'+OBJECT);}

var ObjName = OBJECT.attr("name");

var ObjValue = OBJECT.val();

var ob_defined = true;

}

if ((typeof PARAMS == 'undefined' || PARAMS == null) && ob_defined)

{

var PARAMS = ObjName+'='+ObjValue;// set params to pass via ajax call

}

$j.ajax({

type: "POST",

url: URL,

data: PARAMS, //"name=John&location=Boston",$j('#ContactForm').serialize()

success: function(responseText){

//

//hide the progress bar

//

$j('#loading').hide();

//

if (typeof TARGET != 'undefined')

{

if($j('#'+TARGET).length){TARGET = $j('#'+TARGET);}//if id

else

if($j('.'+TARGET).length){TARGET = $j('.'+TARGET);}//if class

TARGET.html(responseText);

//show TARGET div and display the content with fadeIn transition

TARGET.fadeIn(250);

//$j(TARGET).html(responseText);

//display the body with fadeIn transition

//$j(TARGET).fadeIn(250);

}

}

});

}

/*********************************************************/

$j(document).ready(function(){

//$j(document).on("click", "#client_entry", function(event)

$j(document).on("submit", "#client_entry_form", function(event){

//alert('ohh hhh yes :)');return false;

//prevent default

event.preventDefault();

//hide the middle content and show the loading progress animation

show_hide();

var OBJECT = null;

var URL = $j('#client_entry_form').attr('action');

var PARAMS = $j('#client_entry_form').serialize();

var TARGET = 'middle_content';

///

//run ajax

ajax_CALL(OBJECT , URL , PARAMS , TARGET);

//cancel the anchor tag behaviour or any other default event/trigger

if(!event.isDefaultPrevented())

return false;

});

})

======================================

html5 form

Name:

Phone Number:

Email:

Address:

Additional notes:

2012-03-31

Vishu7

+1

什么是'ajax_submit'?你能提供这个来源吗? –

2012-03-31 21:15:27

+0

@JamesMontagne ajax_submit is ajax_CALL(OBJECT,URL,PARAMS,TARGET);在上面编辑的代码中。 –

2012-04-01 04:56:43

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值