Jquery代码、AJAX表单以及表单外提交
我不知道这段代码出了什么问题:
<script language="javascript"> var jdownloader = false; </script>
<script language="javascript" src="http://127.0.0.1:9666/jdcheck.js"></script>
<script language="javascript">
jQuery(function($) {
$(document).ready(function() {
// Interceptamos el evento submit
if (jdownloader) {
$('#mysubmit').click(function() {
$('#form .jdown, #jdown, .jdown').submit(function() {
// Enviamos el formulario usando AJAX
$.ajax({
type: 'POST',
url: $(this).attr('action'),
data: $(this).serialize(),
// Mostramos un mensaje con la respuesta de PHP
success: function(data) {
$('#result').html(data);
}
})
return false;
});
});
} else {
$('#mysubmit').click(function() {
$('#form .jdown, #jdown, .jdown').submit(function() {
alert('Abre JDownloader.');
return false;
});
});
}
})
});
</script>
HTML
<form ACTION="http://127.0.0.1:9666/flash/addcrypted2" target="hidden" METHOD="POST" id="<?php echo $post->ID; ?>" name="jdown" class="jdown">
<INPUT TYPE="hidden" NAME="passwords" VALUE="myPassword">
<INPUT TYPE="hidden" NAME="source" VALUE="http://jdownloader.org/spielwiese">
<INPUT TYPE="hidden" NAME="jk" VALUE="function f(){ return '31323334353637383930393837363534';}">
<INPUT TYPE="hidden" NAME="crypted" VALUE="<?php echo $crypted; ?>">
</form>
<button id="mysubmit">Submit</button>
我想做的
$('#mysubmit').click(function() {
});
和 ajax POST 表单运行良好,但是当我添加将提交放在表单之外的任何位置时,不起作用。 有什么想法吗?谢谢! =)
i don't know what is going wrong with this code:
<script language="javascript"> var jdownloader = false; </script>
<script language="javascript" src="http://127.0.0.1:9666/jdcheck.js"></script>
<script language="javascript">
jQuery(function($) {
$(document).ready(function() {
// Interceptamos el evento submit
if (jdownloader) {
$('#mysubmit').click(function() {
$('#form .jdown, #jdown, .jdown').submit(function() {
// Enviamos el formulario usando AJAX
$.ajax({
type: 'POST',
url: $(this).attr('action'),
data: $(this).serialize(),
// Mostramos un mensaje con la respuesta de PHP
success: function(data) {
$('#result').html(data);
}
})
return false;
});
});
} else {
$('#mysubmit').click(function() {
$('#form .jdown, #jdown, .jdown').submit(function() {
alert('Abre JDownloader.');
return false;
});
});
}
})
});
</script>
And the HTML
<form ACTION="http://127.0.0.1:9666/flash/addcrypted2" target="hidden" METHOD="POST" id="<?php echo $post->ID; ?>" name="jdown" class="jdown">
<INPUT TYPE="hidden" NAME="passwords" VALUE="myPassword">
<INPUT TYPE="hidden" NAME="source" VALUE="http://jdownloader.org/spielwiese">
<INPUT TYPE="hidden" NAME="jk" VALUE="function f(){ return '31323334353637383930393837363534';}">
<INPUT TYPE="hidden" NAME="crypted" VALUE="<?php echo $crypted; ?>">
</form>
<button id="mysubmit">Submit</button>
What i'm trying to do it's and ajax POST form that goes weel but when i add
$('#mysubmit').click(function() {
});
to put the submit wherever i want outside the form, don't work.
Any ideas? THANKS! =)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我对你的问题有答案..:D
尝试这样做..
希望有帮助..
I have an answer for your problems .. :D
try to do like this ..
hopefully help ..
.submit(function(){})
不提交表单,它只是设置一个在提交表单时应运行的回调(例如在表单内单击提交按钮)。然后调用.submit()
(不带参数)提交表单。The
.submit(function(){})
does not submit the form, it just sets a callback that should be run when the form is submitted (submit button clicked inside the form for example). Calling.submit()
(without arguments) then submits the form.