1
00:00:00,000 --> 00:00:02,340
>> SPIKA 1: Hebu kutekeleza mtandao
ukurasa ambayo inaruhusu watumiaji

2
00:00:02,340 --> 00:00:03,660
kuangalia juu quotes hisa.

3
00:00:03,660 --> 00:00:07,970
Hebu tuseme kwanza kuwa kuna
faili inayoitwa quote.php, lakini hii

4
00:00:07,970 --> 00:00:11,110
inaweza kutekelezwa katika zaidi yoyote
lugha, lakini ambao lengo katika maisha ni

5
00:00:11,110 --> 00:00:15,800
kutarajia HTTP kupata parameter aitwaye
ishara, thamani ambayo ni ya

6
00:00:15,800 --> 00:00:18,120
ishara ya hisa kwa ajili ya ambayo
Ningependa quote.

7
00:00:18,120 --> 00:00:22,530
>> Kwa mfano, kama sisi kuangalia faili hili katika
browser yangu, quote.php, taarifa kwamba

8
00:00:22,530 --> 00:00:26,900
Nimekuwa kupita katika, tayari, alama
ya FB, kwa kuungana.

9
00:00:26,900 --> 00:00:31,060
Na taarifa kwamba kile kurudi
ni JSON kitu na funguo tatu.

10
00:00:31,060 --> 00:00:34,560
Moja kuitwa ishara, na mtu mmoja aitwaye
jina, na mtu mmoja aitwaye bei.

11
00:00:34,560 --> 00:00:38,920
maadili ambayo ni sawa kabisa kuwa
kutoka faili katika swali.

12
00:00:38,920 --> 00:00:41,680
>> Sasa tuangalie mawazo yetu kwa
mwanzo wa baadhi HTML na

13
00:00:41,680 --> 00:00:43,340
JavaScript.

14
00:00:43,340 --> 00:00:48,990
Hapa, katika ajax-0.html, taarifa kwamba ndani ya
ya mwili ukurasa wangu mimi na aina

15
00:00:48,990 --> 00:00:53,430
ambayo ina sifa onsubmit,
thamani ambayo ni ya quote na kurudi

16
00:00:53,430 --> 00:00:57,020
uongo, na hivyo kubainisha kwamba Ningependa
kuwaita kazi JavaScript

17
00:00:57,020 --> 00:00:59,660
aitwaye quote na kisha kurudi uongo.

18
00:00:59,660 --> 00:01:04,459
Wakati huo huo, ndani ya fomu kuwa ni
alama ambao ID ni, unquote quote,

19
00:01:04,459 --> 00:01:07,940
"Symbol," na kisha pembejeo mwingine ambaye
aina ni kuwasilisha kwamba anatoa mimi

20
00:01:07,940 --> 00:01:09,280
kifungo kuwasilisha.

21
00:01:09,280 --> 00:01:13,460
>> Wakati huo huo, ndani ya ukurasa yangu kichwa,
huko ni script tag, chanzo cha

22
00:01:13,460 --> 00:01:18,000
ambayo ni URL kwa jQuery, sana
maarufu JavaScript maktaba, na chini ya

23
00:01:18,000 --> 00:01:21,150
kwamba ni tag mwingine script, ndani ya
ambayo ni mwanzo wa baadhi

24
00:01:21,150 --> 00:01:23,440
JavaScript kwamba mimi mwenyewe nitakuja kuandika.

25
00:01:23,440 --> 00:01:26,900
Hii ni quote kazi ambayo itakuwa
hatimaye kuitwa, na ndani ya

26
00:01:26,900 --> 00:01:31,300
hapa hebu kutangaza variable kuitwa
URL, maalum kwamba thamani ya hii

27
00:01:31,300 --> 00:01:32,590
variable itakuwa quote.php? ishara = ".

28
00:01:32,590 --> 00:01:38,090

29
00:01:38,090 --> 00:01:42,170
>> Na sasa hebu concatenate kwenye mwisho
ya kamba kwamba awali chochote ishara

30
00:01:42,170 --> 00:01:43,840
mtumiaji labda typed.

31
00:01:43,840 --> 00:01:51,770
Hasa, hebu kufanya $ + "" # ishara
hivyo kufafanua kwamba Ningependa

32
00:01:51,770 --> 00:01:54,910
kupata, kwa jQuery kutoka DOM yangu,
hiki ambao kipekee

33
00:01:54,910 --> 00:01:56,430
kitambulisho, alama.

34
00:01:56,430 --> 00:01:59,500
Kumbuka kwamba ni tu Nakala
shamba katika ambao user ni kwenda

35
00:01:59,500 --> 00:02:01,210
aina hiyo ya hisa mfano.

36
00:02:01,210 --> 00:02:05,030
>> Basi hebu piga val, ambayo ni kazi
au mbinu kwamba kupata

37
00:02:05,030 --> 00:02:06,740
thamani kwamba mtumiaji typed in

38
00:02:06,740 --> 00:02:11,540
Na kisha hebu simu jQuery kazi
aitwaye getJSON, kupita katika kama

39
00:02:11,540 --> 00:02:16,010
Hoja ya kwanza kwamba URL, kupita katika, kama
Hoja ya pili, bila

40
00:02:16,010 --> 00:02:18,900
kazi ambayo anatarajia
moja hoja.

41
00:02:18,900 --> 00:02:20,360
Data, tutaweza simu yake.

42
00:02:20,360 --> 00:02:25,130
Na ndani ya kazi hii bila majina,
tutaweza tu kufanya tahadhari, na kisha katika

43
00:02:25,130 --> 00:02:27,940
mabano, data.price.

44
00:02:27,940 --> 00:02:31,470
Kama data, baada ya yote, ni kwamba JSON
kitu kwa mashamba ya tatu -

45
00:02:31,470 --> 00:02:35,100
ishara, jina, na bei, kwa
kufanya data.price nitapata

46
00:02:35,100 --> 00:02:36,640
hasa kwamba thamani.

47
00:02:36,640 --> 00:02:39,000
>> Hebu sasa kuokoa faili na
kufungua it up katika browser.

48
00:02:39,000 --> 00:02:42,230

49
00:02:42,230 --> 00:02:48,760
http://localhost/ajax-0.html.

50
00:02:48,760 --> 00:02:49,870
Hapa tuna aina hiyo.

51
00:02:49,870 --> 00:02:52,890
Hebu aina katika FB kwa Facebook
na kupata quote.

52
00:02:52,890 --> 00:02:55,070
Na huko, basi, ni Picha ya
bei ya hisa za karibuni.

53
00:02:55,070 --> 00:02:58,368