我尝试解决问题,但它不起作用。在控制器中,
我有这段代码,
public function sendFeedbackAjax() {
$feedback = $this->params('feedback_textarea');
$ip = $_SERVER['REMOTE_ADDR'];
$to = 'sinemalar@nokta.com';
$subject = 'Sinemalar Görüş Bildirimi';
$message = 'URL: ' . $this->params('url') . '<br/><br/>E-posta adresi: ' . $this->params('feedback_email') . '<br/><br/>' . $feedback;
$headers = 'MIME-Version: 1.0' . "\r\n" .
'Content-Type: text/html; charset="UTF-8"' . "\r\n" .
'From: noreply@sinemalar.com' . "\r\n" .
'Reply-To: noreply@sinemalar.com' . "\r\n";
$uid = $_SERVER['REMOTE_ADDR'] . 20;
$user = NCore::cache()->remoteCache->get($uid);
if ($user != null) {
$this->sendJSONResponse('Error');
} else {
NCore::cache()->remoteCache->set($uid, $ip, 60 * 60 * 24);
mail($to, $subject, $message, $headers);
$this->sendJSONResponse('OK');
}
}
它检查缓存服务器;如果有密钥,它会发送$this->sendJSONResponse('Error');
,否则会发送$this->sendJSONResponse('OK');
但在JS方面我试试这个:
$.ajax(
{
type: "POST",
url: '/json/common/sendFeedbackAjax',
data: "action=send&url="+url+"&"+values,
success: function(response)
{
if(response == 'OK')
{
$('#feedback_body').html('<p>Görüşleriniz alınmıştır, teşekkür ederiz.</p>');
setTimeout(function () {
hideFeedback();
},2000);
}
else
{
$('#feedback_body').html('<p>Error</p>');
}
}
但它不起作用。可能是什么原因?
答案 0 :(得分:0)
也许你最后错过了});
?