Joh*_*ith 3 javascript ajax jquery
我有一份表格和一份提交.如果有东西被填满,在提交之前我想确保它的价值很高(用ajax),如果是的话,那么我只能让它继续下去.所以,
$('#contact').submit(function() {
// ajax
$.ajax({
type: 'POST',
url: $(this).attr('ajaxgetaccommodationsbyemail'),
success: function(answer) {
here a popup window opens, which waits until I press YES or NO
},
async: false
});
this is when return TRUE or FALSE
there should be something like
do while (popupWindowClosed)
so $.when is not an option
});
Run Code Online (Sandbox Code Playgroud)
您可以使用jQuery阻止提交,然后实际调用本机提交以发送表单
$('#contact').on('submit', function(e) {
e.preventDefault();
var form = this;
$.ajax({
type: 'POST',
url: $(this).attr('ajaxgetaccommodationsbyemail'),
success: function(answer) {
popup(function(yesorno) {
if (yesorno) {
form.submit();
}
});
}
});
});
Run Code Online (Sandbox Code Playgroud)
和async:false删除,因为你应该永远不会做syncronous阿贾克斯.
| 归档时间: |
|
| 查看次数: |
885 次 |
| 最近记录: |