Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何显示警报框?_Javascript_Php - Fatal编程技术网

Javascript 如何显示警报框?

Javascript 如何显示警报框?,javascript,php,Javascript,Php,下面的代码实际上提交了,我需要显示一个警报框,显示消息已经发送 代码: <input type="button" class="Jdvs_Btn" onclick="send_reply('SEND_REPLY', <? echo $clsSurvey->feedback_id?>);" value="SEND" style="font-weight:bold;width:95px;height:30px;float:left; margin-right:5px;" /&

下面的代码实际上提交了,我需要显示一个警报框,显示消息已经发送

代码:

<input type="button" class="Jdvs_Btn" onclick="send_reply('SEND_REPLY', <? echo $clsSurvey->feedback_id?>);" value="SEND" style="font-weight:bold;width:95px;height:30px;float:left; margin-right:5px;" />
}

邮寄代码为: 这是进行验证和其他操作的地方,我需要在这里显示一个警报框 代码:

函数sendReply()
{
echo$this->feedback\u id;
$this->checkAndUpdateReply($this->feedback\u id,$this->content\u to\u send);
$Message=nl2br($this->content\u to\u send);
$mailMessage=”
常量(“产品名称”)-反馈邮件
";
$Message=nl2br($this->content\u to\u send);
$mailMessage.=$Message。“

电子邮件:“.\u电子邮件\u信息。”
注意:-这是一封自动生成的电子邮件,请不要回复此邮件。 "; $mailSubject=常量(“产品名称”)。-反馈回复; $clsEmailTemplate=新的clsEmailTemplate($connect,“”); $clsEmailTempalte->sendMail($mailSubject,$mailMessage,$this->email); }
send_reply
javascript函数的末尾,只需执行一个
警报(“邮件已发送”)

如果您使用的是ajax(例如jQuery),则需要将警报添加到回调中

对于jQuery:

var jqxhr = $.ajax( "example.php" )
  .done(function() {
    alert( "success" );
  })

在javascript函数中,只需添加一行

alert("Message sent");
应该有用

只需发出
警报(“消息已发送”)在js函数的末尾。

如果我这样做(使用jQuery)。我将使用ajax调用发送电子邮件的php文件,如下所示:

您的HTML:

<input type='button' id='submit_form' data-id='<? echo $clsSurvey->feedback_id?>' />

然后只需将您的邮件php添加到mailscript.php中(或者您想叫它什么)。每当脚本完成任务时,done函数将启动,显示您的警报。

欢迎使用,到目前为止您的代码?如果javascript达到该点,则消息已发送,假设您正在运行上述ajax调用。如果(frm.email.value==“”){alert(“请填写您的电子邮件”);返回false;}else{frm.form_action.value=action;frm.submit();alert('Message Sent Successfully');}这就是Goikiu要求您共享所有代码的原因。看起来您正在做一篇简单的文章,因此在提交后页面将更改。在新页面上使用您的alert。
alert("Message sent");
<input type='button' id='submit_form' data-id='<? echo $clsSurvey->feedback_id?>' />
$('#submit_form').click(function(e){

    // To stop the form submitting on button click if you want it to...
    e.preventDefault();

    // Send the id via post to the mailscript
    $.ajax({
        url: 'mailscript.php',
        type: 'POST'
        data: {
            id: $(this).attr('data-id')
        }
    }).done(function(data){
        // Use data if you want to return something from the script and add to the message maybe?
        alert('Add your message in here');
    });

});