ajax post 数据给php , php print 一个string ,前台接受 ,信息是接受到了 ,但是信息的前面多了一个 "<?php " ,请问有人遇到过这个问题么 ,大概是什么问题,能不能告知一下!
var path = window.location.pathname;
jQuery.ajax({
type:"POST",
url:'/thumbsup-callback',
data:{'path':path},
success: thumbsup_load,
error: function(){
alert('An unknown error occurred');
}
})
php --
function thumbsup_load(){
global $user;
if($user->uid){
$uid = $user->uid;
}else{
return false;
}
$path = trim($_POST['path']);
$info = get_node_info($path);
$nid = $info[1];
$query1 = db_select('thumbsup','t')
->fields('t',array('id'))
->condition('t.nid', $nid)
->execute();
$num = $query1->rowCount();
$query = db_select('thumbsup','t')
->fields('t',array('id'))
->condition('t.nid', $nid)
->condition('t.uid',$uid)
->execute();
if($query->rowCount()>0){
print 'ThumbsupAleary|'.$num;
}else{
print 'NotThumbsup'.$num;
}
}
但是console.log出来的是 <?phpThumbsupAleary |2