歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> RHEL5下ajax無法獲取html內容的一種情況

RHEL5下ajax無法獲取html內容的一種情況

日期:2017/2/28 16:09:04   编辑:Linux教程

前台JS:

function test()
{
$("#result").html("<div class=loading>系統正在處理,請稍等...</div>");
$.ajax({
type : "POST",
url :"check_reg.php",
data : $("form").serialize(),
dataType : "html",
success: function(msg){
$("#result").html(msg);
},
error:function(){
$("#result").html("域名狀態繁忙,請稍後檢測。");
}
});
}

後台check_reg.php:

……

$result = file_put_contents("scripts/script_temp.txt",$string);

$url = Config::$base_url.'scripts/script_temp.php';//服務器已做了host映射

$res = Fetcher::down($url);//用的是curl

echo '<pre>';print_r($data);echo '</pre>';exit;

……

在Ubuntu下能獲取數組$data的值,但在RHEL5下怎麼也獲取不到。開始以為是host沒映射,但用了一個test.php(只有一條簡單的輸出語句)測後能獲取內容;後來懷疑是print_r函數的問題,於是改為用<table>標簽的形式,問題依舊;

改用eval()函數,代碼中用return返回結果,問題解決。

Copyright © Linux教程網 All Rights Reserved