我正在尝试通过 ajax 获取一些数据
var ajax1 = false;
ajax1 = new XMLHttpRequest();
ajax1.open("GET","ajax/getolinedata.php");
ajax1.onreadystatechange = function(){
var mylink = ajax1.responseText;
$("a[goal='online']").attr("href",mylink);
}
ajax1.send(null);
这是返回数据的php代码
while($cartRow = mysql_fetch_array($getCartR)){
$pro_name = $cartRow['Product_Name'];
if(strstr($pro_name," ")){
$pro_name = str_replace(" ","_",$cartRow['Product_Name']);
}
$lin .= "&li_".$x."_type=product&li_".$x."_price=".$cartRow['Product_Price']."&li_".$x."_quantity=".$cartRow['Quantity']."&li_".$x."_name=".$pro_name."&li_".$x."_tangible=N";
$x++;
}
echo $lin;
但结果是这样的
<a href="<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/></head><body></body></html>https://www.2checkout.com/checkout/purchase?sid=123456&mode=2CO&li_0_type=product&li_0_price=3700&li_0_quantity=1&li_0_name=iphone_4&li_0_tangible=N&li_1_type=product&li_1_price=3000&li_1_quantity=1&li_1_name=Lumia_720&li_1_tangible=N&li_2_type=product&li_2_price=4500&li_2_quantity=1&li_2_name=ipad_2&li_2_tangible=N&li_3_type=product&li_3_price=2000&li_3_quantity=2&li_3_name=Lumia_520&li_3_tangible=N" goal="online"><img src="images/online.jpg"></a>
它返回整个 html 而该 php 页面中根本没有 html 代码它只是连接到数据库并获取数据的 php 代码有什么帮助吗?