簡體   English   中英

使用ajaxForm插件提交表單時沒有警報

[英]There is no alert when submitting a form using ajaxForm plugin

我如何收到已成功提交表單的警報? 我已經嘗試查看插件的頁面,仍然空手而歸。

這是我到目前為止嘗試過的代碼,也許我的語法有問題:

<script type="text/javascript">

    $(document).ready(function(){

        $('#f1').ajaxForm({

            success: function(){

                alert("Form successfully submitted");

            }

        });

    });

</script>

上面的代碼可以正常工作,並且已成功將所有數據插入到表單中,但是由於某種原因,丟失了在成功提交表單后出現的警報。

這是表單提交時使用的腳本:

<?php
$title=$_REQUEST['articletitle'];
$articlemore=$_REQUEST['editor1'];

include "connection.php";

if (isset($_FILES['image']) && $_FILES['image']['size'] > 0)
{

$type=$_FILES['image']['type'];
// Temporary file name stored on the server
$tmpName = $_FILES['image']['tmp_name'];


// Read the file
$fp = fopen($tmpName, 'r');
$data = fread($fp, filesize($tmpName));
$data = addslashes($data);
fclose($fp);


$query = "INSERT INTO blog(articletitle, articleimage, articlemore) VALUES ('$title', '$data', '$articlemore')";
$results = mysqli_query($link, $query);
if(!$results)
{

    echo "Saving Post Failed";
}
else
{
echo "You have a new Post!";
}
}//end if that checks if there is an image


else
{
echo "No image selected/uploaded";
}

// Close our MySQL Link
mysqli_close($link);

?>

這是語法

         // wait for the DOM to be loaded 
             $(document).ready(function() { 
        // bind 'myForm' and provide a simple callback function 
        $('#myForm').ajaxForm(function() { 
            alert("Thank you for your comment!"); 
        }); 
    }); 

我希望這能幫到您

更改此:

    $('#f1').ajaxForm({

    $('#f1').ajaxForm(function(){

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM