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 Outlook email rather
than having to open a web browser.
My script is below, however I'm slightly confused, because when run in
Outlook or outside the webserver directory it won't work, but run
inside, it will. Can someone explain what I'm doing wrong? I may have
seen somewhere about accessing XML on another server - is it that AJAX
can't access files from a different URL?
Thanks
A
<html>
<style>#body{font-family:arial,helvetica;}</style>
<script language="javascript" type="text/javascript">
function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
ajaxRequest = new XMLHttpRequest();
} catch (e){
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
alert("Your browser broke!");
return false;
}
}
}
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}
}
var pw = document.getElementById('password').value;
var nm = document.getElementById('name').value;
var cn = document.getElementById('cname').value;
var em = document.getElementById('email').value;
var sc = document.getElementById('source').value;
var queryString = "?password=" + pw + "&name=" + nm + "&cname=" + cn
+ "&email=" + em + "&source=" + sc;
ajaxRequest.open("GET", "http://127.0.0.1/bbb%20dev/receive.php" +
queryString, true);
ajaxRequest.send(null);
}
</script>
<body>
<span style="font-family:arial,helvetica;font-size:10pt">
<b>Sender</b>:trial<br />
<b>Email</b>:tr***@trial.com<br />
<b>Company Name</b>:trial<br />
<b>Source</b>:trial
<form name='test' method="post" action="http://127.0.0.1/bbb%20dev/
receive.php">
<input type="hidden" id="password" name="password" value="testpw">
<input type="hidden" id="name" name="name" value="trial">
<input type="hidden" id="cname" name="cname" value="trial">
<input type="hidden" id="email" name="email" value="tr***@trial.com">
<input type="hidden" id="source" name="source" value="trial">
<input type="button" onclick="ajaxFunction()" value="Submit" />
</form>
<div id="ajaxDiv">Here</div>
</body>
</html>