Re: How to call external php script from html? [message #173000 is a reply to message #172998] |
Tue, 15 March 2011 14:59 |
Erwin Moller
Messages: 228 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 3/15/2011 2:57 PM, astral wrote:
> "Erwin Moller" wrote:
>
>>>> >>>>> Hi,
>>>> >>>
>>>> >>>>> it's not working also.
>>>> >>>
>>>> >>>
>>>> >>>> It is working. It is an ancient trick.
>>>> >>>
>>>> >>>> Add an alert to it so see what page is called.
>>>> >>>> You DID change http://www.example.org/myScript.php into something
>>>> >>>> sensible I presume??
>>>> >>>
>>>> >>>
>>>> >>>> <script type="text/javascript">
>>>> >>>> var myPHPScript = "http://www.example.org/myScript.php";
>>>> >>>> var milliSecSinceUE = (new Date()).getTime();
>>>> >>>> var myFakeImage = new Image();
>>>> >>>> alert (myPHPScript +"?nocache="+milliSecSinceUE);
>>>> >>>> myFakeImage.src = myPHPScript +"?nocache="+milliSecSinceUE;
>>>> >>>> </script>
>>>> >>>
>>>> >>>
>>>> >>>> Regards,
>>>> >>>> Erwin Moller
>>>> >>> .............................
>>>> >
>>>> >
>>>> >>> Hi,
>>>> >
>>>> >>> sure, I used correct path in my test.
>>>> >>> Alert says http://www.site.com/test.php?nocache=1300186777680
>>>> >
>>>> >>> so it called script URL.
>>>> >
>>>> >> Hi Astral,
>>>> >
>>>> >> Then what exactly isn't working?
>>>> >
>>>> >> (Assuming you are using Apache, and know where your accesslog is and
>>>> >> have sufficient rights) you can check in your accesslogs if the
>>>> >> script
>>>> >> is called with something like:
>>>> >
>>>> >> tail -n 100 access_log | grep test.php
>>>> >
>>>> >> to see if the request arrived.
>>>> >
>>>> >> Regards,
>>>> >> Erwin Moller
>>>> >
>>>> > ............................
>>>> >
>>>> > Hi,
>>>> >
>>>> > script don't ecxhoes any output in page. I didn't find errors
>>>> > related to
>>>> > script in access log. Perhaps this method to call script isn't
>>>> > supported?
>>>>
>>>> You want the output of the PHP script to appear on your page?
>>>> That was totally unclear to me.
>>>>
>>>> You'll need XMLHTTPRequest for that.
>>>> Not PHP.
>>>>
>>>> Try a javascript newsgroup: --> comp.lang.javascript
>>>>
>>>> Or for a quick introduction (that is not 100% correct):
>>>> http://www.w3schools.com/ajax/default.asp
>>>>
>>>> Good luck.
>>>>
>>>> Regards,
>>>> Erwin Moller
>>> .....................
>>>
>>> No, I mean script parse html and should return results, not PHP script
>>> appear on page.
>>>
>>> Regards,
>>> astral
>>
>> Could you please write down *very* clearly what it is you want?
>> What should the PHP script do?
>> What should the clients browser do?
>> etc.
> -----------
>
> Hi,
>
> well, the php script is a curl script that fetches and displays the
> content of the external site (url defined in code) and should return
> parsed data (echo $html) to the calling page inside a <div> tag. Thus
> when the request data is returned to the calling page it contains the
> content of the external site inside some div. PHP script itself works
> fine, so looking for way to call it directly from the html page.
>
> Regards,
Hi,
Use XMLHTTPRequest for that (Also known as AJAX).
Start by reading through the tutorial:
http://www.w3schools.com/ajax/default.asp
From here on I suggest you finish it in comp.lang.javascript.
This has clearly nothing to do with PHP anymore (which is working fine
as you claim).
One last question, if you don't mind:
I noticed a guy named Corvet in comp.lang.javascript asking the same
questions and posting the code I posted to you, even the first one with
a mistake in it.
Why are you astral here, and Corvet over there?
Regards,
Erwin Moller
--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
|
|
|