Jump to content

simple ajax question


ohdang888

Recommended Posts

thats what i thought, but i'm getting some problems on this:

Theres no errors, but nothing comes up... i type in the box (on test.php) and nothing happens...

 

Go to http://kyforobama.com/test.js for the ajax that i'm calling

 

heres the code on my localhost test.php page:

<html>
<body>
<script src="http://kyforobama.com/test.js" language="javascript" type="text/javascript"></script>

<form name="myForm" method="POST">
Name: <input type="text"
onkeyup="ajaxFunction();" name="username" />
Time: <input type="text" name="time" />
</form>
<div id="testDIV"></div>
</body>
</html>

 

and on receive.php, all it has in it is this:

"this was from kyforobama.com"

 

Thanks!

Link to comment
Share on other sites

Well, a quick look at the js file and I saw one erro right off th ebat:

 

  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById('testDIV'). innerHTML = xmlHttp.responseText;
      }
    }

 

There is an errant space in the reference to the div object.

Link to comment
Share on other sites

ok so maybe i'm looking into the wrong thing...

this is what i want:

User page --> calls file on different server--> file (such as php) is excuted on the same server as the file --> results are sent back to user page

 

 

any idea what i'm looking for?

Link to comment
Share on other sites

About Security

Apache Solution

 

Other solution:

Ajax call to YOUR server.  Your server's php file does a cURL or fopen or w/e to access the site instead, prints the same results you would want to gather off the remote site on your local page.  You get the same data, and handle accordingly.

 

The bypass is that your server opens the other server instead of making javascript do it which usually ends up with the security alerts.

Link to comment
Share on other sites

A php page is executed on the server it's running on.  I was just saying that when you try to call a page that's not running on the same server as the page you're on, you usually get security warnings that stop you.  The work around is to have your ajax call a php page on your server, and have that page call the php page on the other server since php doesn't complain about getting data from remote servers.

Link to comment
Share on other sites

i'm doing this as a learning project....

 

so i guess this could sum up my question... how do the ad networks do it??? They just javascript to call another javascript file on the ad servers and then display the ads from there(i think)... But you can't use javascript to query mysql stuff.. and some ad networks use php and mysql, so that's confusing me.

Link to comment
Share on other sites

I'm not 100% sure, but I would assume they work like Google Analytics where they link to an external .js file. Your allowed to do that, then anything that company runs on their own site is ok within their domain. That then gets returned to your site via the .js inclusion.

Link to comment
Share on other sites

  • 2 weeks later...
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.