reGative Posted June 9, 2011 Report Share Posted June 9, 2011 Tātad esmu izveidojis tādu funkciju, kas uzspiežot uz div elementa ar onclick="speeleet(manavideoid)" blakus parāda video. Bet man šī funkcija nestrādā. Funkcija : <script type='text/javascript'> function speeleet(video_id){ $.get("pages/video.php", { video_id = ""+video_id+""} ); } </script> video.php : <?php$video_id = $_GET['video_id'];$kverijs = mysql_query("SELECT * FROM video WHERE video_id='$video_id'"); $video=mysql_fetch_array($kverijs);?> <div class='virsraksts'><?=$video['title']?></div> <object width="550" height="340"><param name="movie" value="http://www.youtube.com/v/<?=$video['video_id']?>?version=3&hl=lv_LV&rel=0&autoplay=1"></param> <param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/<?=$video['video_id']?>?version=3&hl=lv_LV&rel=0&autoplay=1" type="application/x-shockwave-flash" width="550" height="340" allowscriptaccess="always" allowfullscreen="true"></embed></object> <div class='info'><?=$video['about']?></div> firebug konsolē rāda - Uncaught ReferenceError: speeleet is not defined (anonymous function)/?id=orchestra:39 onclick Kas par vainu manam kodam? Quote Link to comment Share on other sites More sharing options...
0 marcis Posted June 9, 2011 Report Share Posted June 9, 2011 Palasi vēlreiz manuāli http://api.jquery.com/jQuery.get/ Quote Link to comment Share on other sites More sharing options...
0 reGative Posted June 9, 2011 Author Report Share Posted June 9, 2011 $.ajax({ url: url, data: data, success: success, dataType: dataType }); Kas šeit ir kas? url ir pages/video.php un data ir kas? un dataType? Kur to uzzināt? Quote Link to comment Share on other sites More sharing options...
0 xPtv45z Posted June 9, 2011 Report Share Posted June 9, 2011 Tajā pašā manuālī tak ir rakstīts. urlA string containing the URL to which the request is sent. dataA map or string that is sent to the server with the request. success(data, textStatus, jqXHR)A callback function that is executed if the request succeeds. dataTypeThe type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html). Quote Link to comment Share on other sites More sharing options...
0 reGative Posted June 9, 2011 Author Report Share Posted June 9, 2011 pages/video.php ir url tālāk - man vajag video.php?video_id=manavideoid tātad data ir video_id dataType ir html pareizi sapratu? Quote Link to comment Share on other sites More sharing options...
0 marcis Posted June 9, 2011 Report Share Posted June 9, 2011 Manuālis nebeidzas ar pirmo piemēru http://api.jquery.com/jQuery.get/#example-1 $.get("test.cgi", { name: "John", time: "2pm" }, function(data){ alert("Data Loaded: " + data); }); Quote Link to comment Share on other sites More sharing options...
0 rATRIJS Posted June 9, 2011 Report Share Posted June 9, 2011 Kaadeelj ir jauns topiks un netiek turpinaats vecais? http://php.lv/f/topic/19051-javascript-funkcija-mysql-pieprasijums/page__p__148068#entry148068 Quote Link to comment Share on other sites More sharing options...
0 reGative Posted June 9, 2011 Author Report Share Posted June 9, 2011 Pop-up logā parādas errors. sapratu, ka kaut kas manā funkcijā nav pareizi. <script type='text/javascript'> function speeleet(id){ $.get("pages/video.php", { video_id: 'id'}, function(data){ alert("Data Loaded: " + data); }); } </script> netieku skaidrībā, visu ko ar tām pēdiņām izmēģināju. Quote Link to comment Share on other sites More sharing options...
0 reGative Posted June 9, 2011 Author Report Share Posted June 9, 2011 Kaadeelj ir jauns topiks un netiek turpinaats vecais? http://php.lv/f/topic/19051-javascript-funkcija-mysql-pieprasijums/page__p__148068#entry148068 tāpēc, ka nav gluži tas saistīts ar PHP, bet gan ar JavaScript. Quote Link to comment Share on other sites More sharing options...
0 rATRIJS Posted June 9, 2011 Report Share Posted June 9, 2011 Nevis video_id: 'id' Bet gan: video_id: id Preteeji manam ieprieksheejam ieteikumam (ieprieksheejaa topikaa) - iesaku saakt ar JS pamatiem nevis jQuery un tad turpinaat shito, jo tev ir probleemas ar JS sintaksi. Iieprieksheejais topiks ir par to pashu teemu. IMO labaak buutu shos divus apvienot un tad var paarvietot uz JS sadalju... Ja kaads atradiis ieprieksheejo topiku, tad vinjsh taa arii netiks pie iznaakuma, jo tas bus shajaa... Quote Link to comment Share on other sites More sharing options...
0 reGative Posted June 9, 2011 Author Report Share Posted June 9, 2011 (edited) Šādu erroru dabūju, uzpiežot uz tā div elementa (skatīt pievienotajā attēlā) Edited June 9, 2011 by reGative Quote Link to comment Share on other sites More sharing options...
0 rATRIJS Posted June 9, 2011 Report Share Posted June 9, 2011 Tu izslasiiji arii kas tur ir rakstiits? Can't connect to local MySQL server... Visticamaak tev nav starteets MySQL serveris... Quote Link to comment Share on other sites More sharing options...
0 reGative Posted June 9, 2011 Author Report Share Posted June 9, 2011 (edited) Tiku galā. Tikai man vajag to nevis popupā, kā tas ir tagad, bet blakus div elementā ,kurā būtu tas jāielādē. UPDATE: alert("Data Loaded: " + data); vietā ieliku $('div#video_speeleet').html(data); un tagad viss ir ok. Paldies Jums! Edited June 9, 2011 by reGative Quote Link to comment Share on other sites More sharing options...
Question
reGative
Tātad esmu izveidojis tādu funkciju, kas uzspiežot uz div elementa ar onclick="speeleet(manavideoid)" blakus parāda video. Bet man šī funkcija nestrādā.
Funkcija :
video.php :
firebug konsolē rāda - Uncaught ReferenceError: speeleet is not defined
(anonymous function)/?id=orchestra:39
onclick
Kas par vainu manam kodam?
Link to comment
Share on other sites
12 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.