使用.ajaxForm()提交表单时没有警报 [英] There is no alert when submitting a form using .ajaxForm()

查看:39
本文介绍了使用.ajaxForm()提交表单时没有警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Google上进行搜索,因此空手而归,因为我发现的所有答案由于某种原因都不适用于我,也许有人在那里可以查看我的代码:

I have search already on google and come empty handed because all the answer that I found are not working for me for some reason, maybe there is someone out there that can look at my codess:

<html>
<head>
<meta charset="utf-8">
<title>jQuery Adapter &mdash; CKEditor Sample</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
<script src="ckeditor.js"></script>
<script src="adapters/jquery.js"></script>
<script src="jquery.form.js"></script>



<script>

    CKEDITOR.disableAutoInline = true;

    $( document ).ready( function() {
        $( '#editor1' ).ckeditor(); // Use CKEDITOR.replace() if element is <textarea>.
        $( '#editable' ).ckeditor(); // Use CKEDITOR.inline().
    } );

    function setValue() {
        $( '#editor1' ).val( $( 'input#val' ).val() );
    }

</script>
</head>

<body>
<form id="f1" action="some.php" method="post" enctype="multipart/form-data">
<table>
    <tr>
        <td>Title:</td>
        <td><input type="text" name="articletitle" id="articletitle" required/></td>
    </tr>
    <tr>
        <td>Featured Image:</td>
        <td><input name="MAX_FILE_SIZE" value="2097152" type="hidden">
        <input name="image" id="image" type="file" required/></td>
    </tr>
    <tr>
        <td colspan="3"><textarea cols="80" id="editor1" name="editor1" rows="10"></textarea></td>
    </tr>
    <tr>
        <td><input id="save" type="submit" value="Save"></td>
        <td><button id="reset">RESET</button></td>
    </tr>
</table>
</form>


<script type="text/javascript">

$(document).ready(function(){
var options = {
            success: function(){
                //$("#articletitle").val("");
                alert('HELLO');
            }
        };

    $('#f1').ajaxForm(options);
    //$("#button").click(function(){
    //  $('#f1').clearForm();
    //  alert("Successfully Added Record");

    //});

});






</script>
</body>
</html>

我只希望我的用户收到警报,以便他们知道自己的表单已提交.

I just want my user to have an alert so that they are aware that their form has been submitted.

推荐答案

// this is the id of the submit button

$(#submitButtonId").click(function(){

$("#submitButtonId").click(function() {

var url = "path/to/your/script.php"; // the script where you handle the form input.

$.ajax({
       type: "POST",
       url: url,
       data: $("#idForm").serialize(), // serializes the form's elements.
       success: function(data)
       {
           alert(data); // show response from the php script.
       }
     });

return false; // avoid to execute the actual submit of the form.

});

这篇关于使用.ajaxForm()提交表单时没有警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆