473,404 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

ajax not executing php

When a user clicks a link I have it open up a file in a div using ajax.

my code is

<a href="#Find" onclick="javascript:jah('Find.html','content');">F ind</a><br
/>

Where Find.html is an html file on the server. Now when I do this everything
works fine except php code is not being executed.

The jah code is

function jah(url,target) {
// native XMLHttpRequest object
document.getElementById(target).innerHTML = 'sending...';
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = function() {jahDone(target);};
req.open("GET", url, true);
req.send(null);
// IE/Windows ActiveX version
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = function() {jahDone(target);};
req.open("GET", url, true);
req.send();
}
}
}
function jahDone(target) {
// only if req is "loaded"
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
results = req.responseText;
document.getElementById(target).innerHTML = results;
} else {
document.getElementById(target).innerHTML="jah error:\n" +
req.statusText;
}
}
}

The find.html file is something like

<html>
<body>
Find
<?php
echo "Hello";
?>
end Find
</body>
</html>

I get Find and end Find but not hello.

Is there any way to make this work so that the php code is being executed? I
tried using iframes inside the div but there are issues with the size(the
iframe will not expand to fit the div and then there are scrolling issues).

Is it not possible to use php and ajax together like I'm trying to do? (I
figure that the request object is not causing the php excution on the server
side but then it makes it worthless to use ;/)

Thanks,
Jon
Mar 8 '07 #1
2 1173
Rik
Jon Slaughter <Jo***********@Hotmail.comwrote:
When a user clicks a link I have it open up a file in a div using ajax..

<a href="#Find"
onclick="javascript:jah('Find.html','content');">F ind</a><br
/>

Where Find.html is an html file on the server.
<html>
<body>
Find
<?php
echo "Hello";
?>
end Find
</body>
</html>

I get Find and end Find but not hello.
Probably you do, it's just hidden in the HTML source as raw PHP-code,
because your server isn;t set up to parse *.html for php-code (as ist
should be.

Rename your file & links Find.php
--
Rik Wasmus
Posted on Usenet, not any forum you might see this in.
Ask Smart Questions: http://tinyurl.com/anel
Mar 8 '07 #2

"Rik" <lu************@hotmail.comwrote in message
news:op.tou9ryviqnv3q9@misant...
Jon Slaughter <Jo***********@Hotmail.comwrote:
When a user clicks a link I have it open up a file in a div using ajax.

<a href="#Find"
onclick="javascript:jah('Find.html','content');">F ind</a><br
/>

Where Find.html is an html file on the server.
<html>
<body>
Find
<?php
echo "Hello";
?>
end Find
</body>
</html>

I get Find and end Find but not hello.
Probably you do, it's just hidden in the HTML source as raw PHP-code,
because your server isn;t set up to parse *.html for php-code (as ist
should be.

Rename your file & links Find.php
--

Oh, I see. Wasn't thinking.

Thanks,
Jon
Mar 8 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Joel Byrd | last post by:
I am making an AJAX call when any one of a number of inputs in a form (search criteria) are clicked, checked, changed, etc. When the user clicks, checks, whatever, I am trying to display a...
9
by: CeyloR | last post by:
Hello everyone, I have a problem with my Ajax page. I'm jusing prototype-1.4.0.js as framework. I have a function to populate three listboxes. The items in the listboxes are from a MYSQL...
10
by: trpost | last post by:
I am using ajax / php where I am looking up some info from the database and populating a select list dynamically, however I am running into some sort of size limitation with the ajax.response...
1
by: UKuser | last post by:
Hi, I'm trying to get my PHP scripts to email me an email which includes a button to enable a feature, which I'd like to be done via AJAX so the user can open the resulting page within their...
1
by: david | last post by:
First of all, small example: function GetURL() { new Ajax.Request('/updater.php?GetURL=yes', { method:'get', onSuccess: function(transport){ response = transport.responseText;...
2
by: rpollard | last post by:
Hi, I am relatively new to Ajax and am wondering if someone can shed a bit of light on the conceptual part of how Ajax handles its communication. Not knowing a whole lot about Ajax when I...
1
by: shaunwo | last post by:
I'm an AJAX / DOM Novice (at best) and trying to figure out how to write the value to a couple input fields. I don't remember exactly where I got the ajax.js file I'm using from (went to the website...
0
Frinavale
by: Frinavale | last post by:
I have a peculiar problem... Background: I have a function that I don't want the user to execute more than once while they are waiting for it to process; therefore, I disable all of the...
7
by: Andrew Poulos | last post by:
If I have code that looks like this ajax = function(str) { var val = ""; // do some stuff here return val; }; var foo = ajax("string");
1
by: javediq143 | last post by:
Hi All, This is my first post in this forum. I'm developing a CMS for my latest website. This CMS is also in PhP & MySQL. I'm done with the ADD section where the Admin can INSERT new records in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.