Jump to content

Help with calling a .php with js


alphazulu

Recommended Posts

Hello,

 

I am having some issues with a project I am working on.

I am calling a php file on another server using

<script type="text/javascript" src="http://www.website.com/test/file.php"></script>

 

I have the correct type header in my php file and the php outputs JS.

example

echo "document.write(\"some stuff\");";

 

that kind of thing happens alot

 

I also have it outputting a few JS functions,

example

echo 'function dostuff(){ stuff }';

 

the problem I am having is when I add the JS call to the page that calls the php it does nothing

I am using document.ready

 

I am not really sure where to go from here, I know php well enough to do anything I need but I do not know JS at all

 

I can not post the actual source code, I know that would be much easier to troubleshoot this but this is something I just can not do.

Also this needs to be done this way, I need to call to php files on another server so they can do some stuff and then use JS to change some things on another page on another server.

 

This is a content locker, a lot like CPALead and things like that.

 

What am I missing?

 

Any help is greatly appreciated

 

Link to comment
Share on other sites

Ok

 

Now I see what is happening, but still at a loss for some reason.  Could be because I have been working on this for 10 hours today, or maybe I don't know what to do here.

 

it is simply printing the JS as text, I can post this since its nothing

 

this is what firebug shows me

<html>
<head>
<script src="http://www.lightspeedmedia.net/test/contentlocker.php" type="text/javascript">
function setupgateway(){
var Left = $(window).width() /2;
Left = Left - $('#gatewaydiv').width()/2;
var Top = $(window).height() /2;
Top = Top - $('#gatewaydiv').height()/2;
$('#gatewaydiv').css('top', Top+'px').css('left', Left+'px').css('display', 'inline');
$('#gatewayDimmer').width($('html').width());
$('#gatewayDimmer').height($('html').height());
$('#gatewayDimmer').css('display','block');}function removegateway(){
$('#gatewaydiv').css('display', 'none');
$('#gatewayDimmer').css('display','none');}document.write("<meta http-equiv="refresh" content="5
">);document.write("<link rel="stylesheet" type="text/css" href="style.css" />");document.write("<div id="gatewayDimmer"></div>");document.write("<div id="gatewaydiv">");document.write("<ul id="OfferList">");document.write("<h1>You Must Complete An Offer To Unlock Page
</h1>");document.write("<span id="gatewayMessage">Files Locked
</span>");document.write("<br /><br />");document.write("<li><center><a href="www.website.com
" class="offerlink" target="blank">Click Here Man
</a></center></li>");document.write("<li><center><a href="www.website.com
" class="offerlink" target="blank">Click Here
</a></center></li>");document.write("<li><center><a href="www.website.com
" class="offerlink" target="blank">Click Here
</a></center></li>");document.write("<li><center><a href="www.website.com
" class="offerlink" target="blank">Click Here
</a></center></li>");document.write("</ul><br /><br /><center><h3><b>This page will automatically refresh once the offer is finished
</b></h3></center></div>");$(document).ready(function()
{
setupgateway();
});
</script>
</head>
<body>
</html>

Link to comment
Share on other sites

Well... this code makes use of jquery.  I didn't look that carefully at your script but I don't see where you're including the jquery library.  Also, your page snippet is not well formed, and there is none of the divs that are referenced or for that matter markup of any kind.  It's not going to work if you don't have a well formed html document.

Link to comment
Share on other sites

hmm jquery, will fix that.

 

it references an external .css, which is actually made by the php file when the script is run, which works just fine

 

I will work on reforming it, but this is ultimately going to work on any page where the correct call to the .php file is made.

 

I will let you know if i can get it to work

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.