嗨,我有这段代码,这是带有 ajax 的 xml,我希望从 res 获得的返回值不包含 html 标记,因为它总是返回这个值。例如我应该返回一个值 1 而不是 ajax 返回这个值
<html>
</html>
1
这是我的 xml 代码
function sendEscalationEmail()
{
var xmlHttp = GetXmlHttpObject();
if (xmlHttp==null) { alert ("The system cannot process your request.\nPlease use browser that supports AJAX!"); return; }
var params1 = $('#formTrans').serialize();
var params2 = $('#formClient').serialize();
xmlHttp.onreadystatechange = function generateOutput()
{
if (xmlHttp.readyState==4 && xmlHttp.status==200)
{
var res = xmlHttp.responseText;
if (res.indexOf('1')<-1) alert('Transaction is saved but there has been an error sending the details to your supervisor\'s email.\nKindly contact the system administrator.');
else
{
alert('Transaction submitted and sent to your supervisor\'s email.');
document.getElementById('emailpreview').innerHTML = '';
$("#emailpreview").dialog("close");
}
}
};
xmlHttp.open('GET', 'send.esemail.php?'+params1+'&'+params2, true);
xmlHttp.send('');
}
这是 send.esemail.php 的代码
$arrTo[] = "xx@xx.com";
$mail = new htmlMimeMail();
$mail->setTextCharset('utf-8');
$mail->setHtmlCharset('utf-8');
$mail->setHeadCharset('utf-8');
$mail->setSMTPParams($SMTPServer, $SMTPPort);
$mail->setHtml($strHTML);
$mail->setFrom("xxxxx");
$mail->setSubject($strSubject);
$mail->setReturnPath('xx@xx,net');
$mail->setBcc("xx@eg.net");
$result = $mail->send($arrTo);
echo $result;
我如何从返回值中删除标签,这样我就可以摆脱使用 indexOf 来找到正确的响应。$result 应该只输出1
,但它有<html></html> 1
.