你有一个表格,在jquery插件“openid”的帮助下提交。现在,当我点击google_button时,每件事都运行正常但是当我点击aol时它会打开对话框并提交表单(当form.submit与return false被注释掉了)。当我删除评论时,aol将正常工作,只有aol对话框打开并且表单未提交,但在这种情况下也不会提交谷歌表单。
请帮帮我
=============================================== =================================
<form action="example.php" method="post" >
<input type="image" src="images/google_button.png" id='https://www.google.com/accounts/o8/id' class="google"/>
<input type="image" src="images/AOL_button.png" id='http://openid.aol.com/' class='aol' />
</form>
=============================================== =================================
<script type="text/javascript">
$(document).ready(function(){
$('form').openid();
})
</script>
=============================================== =================================
(function($){
$.fn.openid = function() {
$('input').click(function(e){
var provider = $(this).attr('class');
if (provider == 'aol') {
$("#dialog").dialog();
/*$('form').submit(function(){
return false;
})*/
}
else{
var provider_url = $(this).attr('id'); //get id
var myinput = $('<input type="hidden" name="provider_url"/>').val(provider_url);
$('form').append(myinput);
$('form').submit();
}
})
}
})(jQuery);
=============================================== ================================
答案 0 :(得分:0)
尝试在if else
构建后发送表单。
答案 1 :(得分:0)
(function($){
$.fn.openid = function() {
$('input').click(function(e){
var provider = $(this).attr('class');
if (provider == 'aol') {
$("#dialog").dialog();
/*$('form').submit(function(){
return false;
})*/
***return false;*** //add return false in this section
}
else{
var provider_url = $(this).attr('id'); //get id
var myinput = $('<input type="hidden" name="provider_url"/>').val(provider_url);
$('form').append(myinput);
$('form').submit();
}
})
}
})(jQuery);