Ms7 Search
Google 搜尋 翻譯
calendar
« 九月 2024 »
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
近期文章
文章分類
網站連結
Syndicate

« | »

jquery 使用 ajax 傳回 data 用 json,後端用 php 取得字串與陣列的用法

2018-09-21 @ 20:58 in PHP, JavaScript, Sql

jquery 使用 ajax 傳回 data 用 json,後端用 php 取得字串與陣列的用法
$test1 = "test";
$test2 = array("a1"=>"111","a2"=>"222");
php用 json_encode(array("data1"=>"$test1"));
網路上這樣用,那在資料是字串時沒有問題,在 ajax 經過 var item = JSON.parse(data);用 item["data1"] 可以讀到傳回資料
php用 json_encode(array("data2"=>"$test2"));
網路上這樣用,那在資料是陣列時,在 ajax 經過 var item = JSON.parse(data);用 item["data2"]["a1"] 讀不到傳回資料,將後面資料的 " 取消,不管是字串或陣列都可以也就是
php用 json_encode(array("data1"=>$test1));
php用 json_encode(array("data2"=>$test2));
這是測試使用結果,正不正確不知道,反正我的問題解決了

迴響

jquery 使用 ajax 傳回 data 用 json,後端用 php 取得字串與陣列的用法 | 豬窩

My brother suggested I might like this web site.
He was totally right. This post actually made my day.
You cann't imagine simply how much time I had spent for this info!

Thanks!

作者 web hosting @ 14:41, 2020-08-10

jquery 使用 ajax 傳回 data 用 json,後端用 php 取得字串與陣列的用法 | 豬窩

Great goods from you, man. I have understand your stuff previous to
and you're just extremely wonderful. I really like what you have acquired here,
certainly like what you are saying and the way in which you say it.
You make it entertaining and you still take care of to keep it smart.

I can not wait to read far more from you. This is really
a terrific website.

作者 web hosting reviews @ 03:14, 2020-08-11

jquery 使用 ajax 傳回 data 用 json,後端用 php 取得字串與陣列的用法 | 豬窩

Oh my goodness! Impressive article dude! Thanks, However I am going through troubles with
your RSS. I don't understand why I am unable to subscribe to it.
Is there anybody else having similar RSS issues? Anyone that knows the answer will
you kindly respond? Thanks!!

作者 website hosting @ 13:14, 2020-08-14

jquery 使用 ajax 傳回 data 用 json,後端用 php 取得字串與陣列的用法 | 豬窩

Useful info. Lucky me I discovered your web site by chance, and I'm surprised why this accident didn't happened in advance!
I bookmarked it.

作者 website hosting companies @ 19:11, 2020-08-14
發表迴響
 authimage