ASP在发送电子邮件后返回json数组
我最初准备好了一个 php 邮件脚本,但服务器没有 php,所以我只剩下弄清楚 asp 了。
这是我的 php 代码:
<?php
require_once('../class.phpmailer.php');
$mail = new PHPMailer();
$mail->SetFrom($email, $name);
$mail->AddAddress('[email protected]','john');
$mail->Subject = "A message from contact form";
$mail->MsgHTML($note);
if(!$mail->Send()) {
$the_return = array('request'=>'failed','prompt'=>$prompt);
echo json_encode($the_return);
} else {
$the_return = array('request'=>'success');
echo json_encode($the_return);
}
die();
?>
这里重要的是尝试重新创建 json 数组并对其进行编码。我将通过 jquery ajax 调用运行此脚本,因此我想将这些值返回到联系表单。
I initially had a php mail script ready, but the server didn't have php, so I'm left with figuring out asp.
Here is my php code:
<?php
require_once('../class.phpmailer.php');
$mail = new PHPMailer();
$mail->SetFrom($email, $name);
$mail->AddAddress('[email protected]','john');
$mail->Subject = "A message from contact form";
$mail->MsgHTML($note);
if(!$mail->Send()) {
$the_return = array('request'=>'failed','prompt'=>$prompt);
echo json_encode($the_return);
} else {
$the_return = array('request'=>'success');
echo json_encode($the_return);
}
die();
?>
what is important here is to try and recreate the creation of a json array and encoding it. I'm going to be running this script through a jquery ajax call so I want to return these values back to the contact form.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经典 ASP 没有内置的 JSON 编码功能。
您可以直接写入响应或使用类似 http://code.google.com/p/aspjsonrpc/source/browse/trunk/ASP-JSON-RPC/jsonParser.asp
如果你想要更简单的,直接写:
Classic ASP doen't have a built in JSON encode function.
You can write directly to the response or use something like http://code.google.com/p/aspjsonrpc/source/browse/trunk/ASP-JSON-RPC/jsonParser.asp
If you want something more simple and write directly: