作者B9 (叶酸酸)
看板Ajax
标题Re: [问题] 用jquery将值不同步存入阵列
时间Sun Jul 31 11:16:38 2011
※ 引述《BM0108 (冲)》之铭言:
: 我要用ajax的方式从其他地方读入数值到我的javascript中
: 每读入一笔资料(可能是str or obj),就将这笔资料存到array的一个index
: 这是我第一次用jquery,查不到比较适当的写法
: 有请版上前辈给点建议,谢谢!
既然你是拿资料,那我就假设你用 GET。请看这个范例:
jQuery.get() – jQuery API
http://api.jquery.com/jQuery.get/
Example: Alert out the results from requesting test.php
(HTML or XML, depending on what was returned).
如果刚好是跟 server 拿 json 的话,可以用 getJSON
jQuery.getJSON() – jQuery API
http://api.jquery.com/jQuery.getJSON/
还有其他的请看一下:
Shorthand Methods – jQuery API
http://api.jquery.com/category/ajax/shorthand-methods/
> -------------------------------------------------------------------------- <
顺便告诉你 jQuery API 要怎麽使用好了,很久以前我刚开始用的时候也觉得看不太懂。
jQuery API
http://api.jquery.com/ 这是 jquery api document。
sidebar 有个 section 叫 Browse the jQuery API
下面很多分类:ajax、attributes 还有很多,各分类还有小分类。
想要知道那个分类可以干嘛,大部份的时候只要点进去,在 content 的上面会介绍。
多看文件就会知道要用什麽 method 了。
--
Oni devas ami animalojn. Ili estas tiel bongustaj.
One should love animals. They are so tasty.
每个人都应该爱动物,他们是如此美味。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 175.180.52.143
1F:推 BM0108:thank you so much!! 07/31 13:38