0
我有一個後端CGI腳本,通過Ajax調用返回我下面的文字中出現問題時:JS更換功能不按預期工作
<p>A problem occurred in a Python script.
<p> /bin/cgi-bin/LOGS/tmpslM4pu.txt contains the description of this error.
我試圖像下面顯示出來:
$.ajax({
type: "POST",
url: "runcgi.py",
data:
{
'my_data' : 'test'
},
success: function(html)
{
if(..test for success..)
{
}
else
{
var StrippedString = $(html).toString().replace(/(<([^>]+)>)/ig,""); var StrippedString = $(html).toString().replace(/(<([^>]+)>)/ig,"");
$("p").html(StrippedString);
}
});
而下面是我的HTML代碼:
<body>
<p></p>
</body>
但我看到下面的輸出在我的瀏覽器:
[object Object]
我該如何解決這個問題?
使用console.log(html)在Firefox中使用Google Chrome或Firebug,然後在控制檯視圖中檢查元素。 – Christian