Jump to content

[SOLVED] java script that will launch a php script in the background


M.O.S. Studios

Recommended Posts

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!

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.