简体   繁体   English

Ajax在jQuery Mobile弹出窗口中不起作用

[英]Ajax not working in a jQuery Mobile popup

I am using a jQuery mobile popup as an editing form. 我正在使用jQuery移动弹出窗口作为编辑表单。 When the user clicks a submit button, it should take the info on the form and do an SQL query to update the database. 当用户单击“提交”按钮时,应该在表单上获取信息并执行SQL查询以更新数据库。 For some reason as soon as it gets to the ajax call, it breaks. 由于某种原因,一旦到达ajax调用,它就会中断。 I have tried using a normal submit button and also just a normal button that's binded to a jQuery function and both do the same thing. 我尝试使用普通的提交按钮,也只是使用绑定到jQuery函数的普通按钮,两者都做相同的事情。

$('form').submit(function(event) {
    event.preventDefault();
    alert("checkpoint 1");
    $.ajax( {
        type: 'POST',
        url: process_edit.php,
        data: $(this).serialize(),
        success: function(data) {
            //do something
        }
    } );
    alert("checkpoint 2");
});

I get the "checkpoint 1" alert box to show up, but then the jQuery mobile popup closes and "checkpoint 2" never shows up. 我看到“ checkpoint 1”警报框出现,但是jQuery移动弹出窗口关闭,并且“ checkpoint 2”从不显示。

There is a typo error you missed the single quotes ' around the url part 您在url部分错漏了单引号'

$('form').submit(function(event) {
    event.preventDefault();
    alert("checkpoint 1");
    $.ajax({
        type: 'POST',
        url: 'process_edit.php',
        data: $(this).serialize(),
        success: function(data) {
            //do something
        }
    });
    alert("checkpoint 2");
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM