1. 程式人生 > >ajax接收php返回得到一堆html代碼

ajax接收php返回得到一堆html代碼

table 什麽 也會 trap align all 返回 mem oca

ajax接收php返回得到一堆html代碼

一、 錯誤代碼:

<font size=‘1‘><table class=‘xdebug-error xe-notice‘ dir=‘ltr‘ border=‘1‘ cellspacing=‘0‘ cellpadding=‘1‘>    
    <tr><th align=‘left‘ bgcolor=‘#f57900‘ colspan="5"><span style=‘background-color: #cc0000; color: #fce94f; font-size: x-large;‘
>( ! )</span> Notice: Undefined variable: _SESSION in D:\wamp64\www\lost_and_Found\bootstrap\phpfiles\custom_sendMail.php on line <i>11</i></th></tr> <tr><th align=‘left‘ bgcolor=‘#e9b96e‘ colspan=‘5‘>Call Stack</th></tr> <tr><
th align=‘center‘ bgcolor=‘#eeeeec‘>#</th><th align=‘left‘ bgcolor=‘#eeeeec‘>Time</th><th align=‘left‘ bgcolor=‘#eeeeec‘>Memory</th><th align=‘left‘ bgcolor=‘#eeeeec‘>Function</th><th align=‘left‘ bgcolor=‘#eeeeec‘>Location</th></tr> <
tr><td bgcolor=‘#eeeeec‘ align=‘center‘>1</td><td bgcolor=‘#eeeeec‘ align=‘center‘>0.0004</td><td bgcolor=‘#eeeeec‘ align=‘right‘>366336</td><td bgcolor=‘#eeeeec‘>{main}( )</td><td title=‘D:\wamp64\www\lost_and_Found\bootstrap\phpfiles\custom_sendMail.php‘ bgcolor=‘#eeeeec‘>...\custom_sendMail.php<b>:</b>0</td></tr> </table></font> <pre class=‘xdebug-var-dump‘ dir=‘ltr‘> <small>D:\wamp64\www\lost_and_Found\bootstrap\phpfiles\custom_sendMail.php:12:</small><font color=‘#3465a4‘>null</font> </pre>

二、 為什麽出現?

相信會有人看到一堆代碼之後頭皮發麻。新手更是不知道如何產生的。

實際上,既然這是一堆HTML代碼,那把它復制到文件中,在瀏覽器打開不就知道了嘛?

那怎麽復制?因為很多人出現這個錯誤都是在用ajax提交數據給PHP,PHP返回的亂碼數據,往往是alert輸出的,在提示框不能復制。

三、 解決方案

首先打開Chrome調試,

技術分享

當發起ajax請求之後,在console便會出現如圖所示的日誌。點它~(輕點)

技術分享

然後出現如圖的變化,ajax提交地址對應的php也會顯示出來,點擊你要提交的那個php。

技術分享

點擊Response就可以復制了。這裏可以查看返回的數據。

另外Headers可以查看提交的數據等信息。

復制之後到HTML文件中粘貼打開。

技術分享

哎呦我曹..這不就是PHP出錯的提示嗎。原來是提交地址PHP邏輯出錯。那就改吧。而且,你看上圖,把出錯的地方以及錯誤大致類型都指明了。按照說明去修改就OK。我的上圖是沒有開啟seesion_start導致的。

技術分享

ajax接收php返回得到一堆html代碼