$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