thinkphp中用ajax的問題 想做個二級聯動

來源:互聯網
上載者:User
public function Billing()
{
//後台ajax驗證
$result = array();
$cate['S_Customer'] =$_POST['S_Customer'];
$result = M('Customer')->where( $cate)->field('phone,c_name')->select();
$this->ajaxReturn($result,"json");
$this->display();
}

為什麼顯示的只是數組,而我原網頁不顯示了,,,難道我的輸出有問題?


只出現[{"phone":"13802149988","c_name":"\u5f20\u4e09"},{"phone":"13802144455","c_name":"\u674e\u56db"}],F12檢查,發現頁面上也就只有這數組,,其他東西都沒有。。





怎麼樣才能實現二級聯動呢。。


回複討論(解決方案)

求大神出答案!!。。

$this->ajaxReturn 裡面有個exit

$this->ajaxReturn 裡面有個exit


嗯,,然後呢,我是初學者,所以還是不明白您的意思,詳細點。。謝了!

thinkphp 的 ajax 響應預設是返回 json 的
再說你也通知 $.ajax 返回的是 json 替我解碼(dataType:'json',)
但是你的返回結果中並沒有 success 和 msg 項
而 $('#phone').html(data.msg) 中,data.msg 的內容應該是 html 代碼

不要隨意的去抄人家的代碼,要理解為什麼要那麼寫

thinkphp 的 ajax 響應預設是返回 json 的
再說你也通知 $.ajax 返回的是 json 替我解碼(dataType:'json',)
但是你的返回結果中並沒有 success 和 msg 項
而 $('#phone').html(data.msg) 中,data.msg 的內容應該是 html 代碼

不要隨意的去抄人家的代碼,要理解為什麼要那麼寫


謝謝指點!
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.