M.O.S. Studios Posted May 25, 2009 Share Posted May 25, 2009 hey guys, I'm working on a site that streams video content. i want to give the user the option to rate what he/she is watching. I would like to make a button that opens an invisible window, or launches a php script, either way i would like it not to have to reload the entire page (so that the user doesn't have to reload the video) any ideas?? thanks in advance! Quote Link to comment Share on other sites More sharing options...
lonewolf217 Posted May 25, 2009 Share Posted May 25, 2009 javascript cannot call PHP. but you can you AJAX to do this without reloading the page Quote Link to comment Share on other sites More sharing options...
Axeia Posted May 25, 2009 Share Posted May 25, 2009 Either ajax or an iframe. Quote Link to comment Share on other sites More sharing options...
M.O.S. Studios Posted May 26, 2009 Author Share Posted May 26, 2009 i'm thinking about using an iframe, i did some tests just a few mins ago and it looks like it will work, the only problem is that it will make it a lot easier for bots to attack my db that way. i know zero Ajax, Do u guys know a tutorial I can look up that will show me what i will need to know on that subject? or the name of the subject to google? Quote Link to comment Share on other sites More sharing options...
lonewolf217 Posted May 26, 2009 Share Posted May 26, 2009 there are links in the AJAX forum on this site Quote Link to comment Share on other sites More sharing options...
Axeia Posted May 26, 2009 Share Posted May 26, 2009 Most javascript frameworks have excellent ajax capabilities, didn't know jquery at all but a few minute of documentation reading and I had my function hooked up to ajax in no time. Normally I'd refer to w3schools but I find their ajax tutorial a bit too brief. Quote Link to comment Share on other sites More sharing options...
Psycho Posted May 26, 2009 Share Posted May 26, 2009 Do u guys know a tutorial I can look up that will show me what i will need to know on that subject? or the name of the subject to google? That's a tough one, try this: http://lmgtfy.com/?q=ajax+tutorial On a serious note, I would highly suggest NOT using an IFRAME. There are just too many issues that I have encountered with them over the years. AJAX is the perfect solution for what you are wanting to do. javascript cannot call PHP. but you can you AJAX to do this without reloading the page Um, isn't that what the AJAX is doing? The JavaScript IS calling a PHP page! Quote Link to comment Share on other sites More sharing options...
M.O.S. Studios Posted May 26, 2009 Author Share Posted May 26, 2009 ok guys i got it done, thatnks for all your help here is the code i did java header <script language="JavaScript" type="text/javascript"> function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { //Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } function rate_data(id){ xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Your browser does not support AJAX!"); return; } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete"){ document.getElementById('rate-responce').innerHTML=xmlhttp.responseText; } } var url="send.php"; url=url+"?score="+id; xmlhttp.open("GET",url,true); xmlhttp.send(null); } </script> then for each star icon i did this <li><a href="#" onclick="rate_data(1);" title="1 out of 10" class="r1-unit rater" rel="nofollow">1</a></li> thanks again for all the help Quote Link to comment Share on other sites More sharing options...
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.