简体   繁体   English

jQuery脚本运行不正常,警报未显示

[英]jQuery script doesn't work fully well, alert doesn't show up

I have this jquery script: 我有这个jQuery脚本:

$('input[name="add-post"]').on('click', function(form) {
    form.preventDefault();
    for ( instance in CKEDITOR.instances )
    CKEDITOR.instances[instance].updateElement();
    $.ajax({
        type: 'POST',
        url: 'add-post',
        data: $('form.new-post').serialize(),
        dataType: 'json',
        succes: function(data)
        {
            alert('123');

        },
        error: function(data)
        {
            alert('321');
        }
    });
});

And technically it works as it should. 从技术上讲,它可以正常工作。 Ajax goes to add-post php script, post is added to database. Ajax去添加帖子php脚本,将帖子添加到数据库。 Whole PHP script is done as it should. 整个PHP脚本均已完成。

But

alert('123');

Alert doesn't show up. 警报未显示。 No 123. No 321. There is no alert. 否123。否321。没有警报。

Why this doesn't work? 为什么这不起作用? Despite PHP's script by ajax did all good. 尽管ajax编写了PHP脚本,但一切都很好。

(note: no information in console chrome after submit) (注意:提交后,控制台镶边中没有任何信息)


Some additional information: 一些其他信息:

When duplicate post is submitted (already exist in DB) 321 alert is shown. 提交重复的帖子时(DB中已经存在),将显示321警报。

But still no 123 alert. 但是仍然没有123警报。 When it is success. 成功的时候。

use this 用这个

success: function(data) 成功:功能(数据)

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

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