我无法搞清楚这一点。我的默认布局中有一个名为quoteform的元素。这个元素的表单有几个文本框,复选框,提交按钮等。我想提交表单并发送包含所有这些数据的邮件。在成功发送邮件后,我想用另一个div替换当前div,该div表示Message已成功发送。
我已经使用了cakephp ajax来做这件事,但是在提交时,它不会发送邮件或刷新带有消息的div。
以下是我的代码
行情/ quoteform.ctp
<?php
$this->requestAction('Quotes/index');
?>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<div id="quotenext">
<?php echo $this->Form->create('Quote'); ?>
<div class="inputboxa"><?php echo $this->Form->input(
'name', array(
'id' => 'name',
'style' => 'width:440px;height:20px;font-size:8pt; background-color:black;color:white;resize:none;border:none;padding-left:5px;padding-top:5px;',
'placeholder' => 'NAME*', 'type' => 'textarea'
)); ?></div>
<br>
<div class="inputboxb"><?php echo $this->Form->input(
'email', array(
'id' => 'email', 'placeholder' => 'E-MAIL*',
'style' => 'width:440px;font-size:8pt;height:20px;resize:none;background-color:black;color:white;border:none;padding-left:5px;padding-top:5px;',
'type' => 'textarea'
)); ?></div>
<br>
<div class="inputboxc"><?php echo $this->Form->input(
'phone', array(
'id' => 'phone', 'placeholder' => 'PHONE*',
'style' => 'width:440px;font-size:8pt;height:20px;resize:none;background-color:black;color:white;border:none;padding-left:5px;padding-top:5px;',
'type' => 'textarea'
)); ?></div>
<br>
<?php
echo $this->Js->submit(
'SUBMIT', array(
'success' => $this->Js->get('#quotenext')->effect('hide'),
'update' => $this->Js->get('#quotesent')->effect('show')
)); ?>
<!--</a>-->
div id="quotesent" class="slide" style="display:none"">
<div id="quotebottom">
<div id="message">
<?php echo $this->Session->flash(); ?>
<div id="closediv">CLOSE</div>
<?php echo $this->Form->end(); ?>
</div>
</div>
</div>
QuotesController.php
class QuotesController extends AppController {
public $helpers = array('Js' => array('jquery1.9.1.min'));
public $components = array('RequestHandler');
public function index() {
$email = new CakeEmail();
if ($this->request->is('post')) {
$this->Quote->set($this->request->data);
if ($this->Quote->save($this->request->data)) {
if ($this->RequestHandler->isAjax()) {
$name = $this->request->data['Quote']['name'];
$mail = $this->request->data['Quote']['email'];
$email->from(array($mail => $name));
$email->to('anniecherian79@gmail.com');
if (isset($this->request->data['Quote']['solutioncheckbox'])) {
$ctime = implode(',', $this->request->data['Quote']['solutioncheckbox']);
}
$message = "Phone No : " . $this->request->data['Quote']['phone'] . "\n\nBest Contact time :" . $ctime . " \n\nMessage : " . $this->request->data['Quote']['message'];
$email->subject('BlackNova Website Instant Quote Form');
$email->send($message);
if ($email->send($message)) {
$this->Session->setFlash('Quote Processed..Thank You For Visiting Our Website!!!');
$this->render('/view/elements/quotes/quoteform.ctp');
}
}
}
}
}
}
简而言之,在成功结束邮件之后,我想在#quotesent中显示该消息,这可能吗?