For your first question, the served HTML of the PHP must be valid HTML, and the page you are importing it to may need to be PHP. Also, any paths on the PHP page should be absolute. The PHP page must be on the same domain as the page you are importing it to, and must look this way to the browser. PHP must be enabled on the server, and there may be no restrictions set in PHP's configuration on its use that may hinder the import process. There could be other issues.
As to your second question, in general yes - as many operations as desired may be carried out onclick of an element. In this particular case though, once the page is reloaded, any further activity via javascript must be carried out onload or as the page loads in the browser. If you have a PHP enabled server, this could be assisted by PHP by passing a query value to the page (but the index would have to be PHP). Javascript itself can retrieve a query value and carry out an action on the reloaded page, ex:
Code:
<script type="text/javascript">
function getQval(n, m) {
/*my n=name, m=searchString(optional)*/
if(!arguments[0]||typeof n!='string')
return null;
var r=new RegExp('[?&;]'+n+'=([^&;#]*)'), m=arguments[1]?m:location.search;
return (m=r.exec(m))? unescape(m[1]) : null;
}
if(getQval('queryName') === 'expectedQueryValue')
window.onload = function(){
ajaxpage('test.htm', 'contentarea');
};
</script>
So let's say you want to pass test as the query value for p. All you need is a normal link:
HTML Code:
<a href="index.htm?p=test">Index w/test</a>
Then in the above code, where I have:
Code:
if(getQval('queryName') === 'expectedQueryValue')
Make it like so:
Code:
if(getQval('p') === 'test')
If you want more help:
Please post a link to the page on your site that contains the problematic code so we can check it out.
Bookmarks