嗨我有这个代码这是带有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
。
答案 0 :(得分:0)
在send.esemail.php中 写 echo strip_tags($ result); 它应该只返回1.