PDA

View Full Version : Internet Explorer/Safari Javascript Error


polexian
11-30-2009, 04:26 PM
I am running an AJAX based php call and when I run the code to send data via ajax to a webpage to update my tables it sends this error in internet explorer. In Safari the page doesn't even display.

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET CLR 4.0.20506)
Timestamp: Mon, 30 Nov 2009 15:21:39 UTC


Message: 'document.myForm.time' is null or not an object
Line: 73
Char: 4
Code: 0
URI: mysite/start.php?_fb_q=1&fb_sig_in_iframe=1&fb_sig_iframe_key=34173cb38f07f89ddbebc2ac9128303f&fb_sig_locale=en_US&fb_sig_in_new_facebook=1&fb_sig_time=1259594459.2967&fb_sig_added=1&fb_sig_profile_update_time=1256586887&fb_sig_expires=1259683200&fb_sig_user=649866504&fb_sig_session_key=2.Rl7af9j6QO5ZJkvCEs98kA__.86400.1259683200-649866504&fb_sig_ss=E01CE87HKqiz05gziXkevA__&fb_sig_cookie_sig=c28317b99d6f81042b69991a601c19e9&fb_sig_ext_perms=auto_publish_recent_activity&fb_sig_api_key=761fad7021e81f4ba79fb8ae7f169b2e&fb_sig_app_id=156970644891&fb_sig=add7e8f73b1a89b31fb378fa716c1b4d


Message: 'document.myForm.time' is null or not an object
Line: 73
Char: 4
Code: 0
URI: mysite/start.php?_fb_q=1&fb_sig_in_iframe=1&fb_sig_iframe_key=34173cb38f07f89ddbebc2ac9128303f&fb_sig_locale=en_US&fb_sig_in_new_facebook=1&fb_sig_time=1259594459.2967&fb_sig_added=1&fb_sig_profile_update_time=1256586887&fb_sig_expires=1259683200&fb_sig_user=649866504&fb_sig_session_key=2.Rl7af9j6QO5ZJkvCEs98kA__.86400.1259683200-649866504&fb_sig_ss=E01CE87HKqiz05gziXkevA__&fb_sig_cookie_sig=c28317b99d6f81042b69991a601c19e9&fb_sig_ext_perms=auto_publish_recent_activity&fb_sig_api_key=761fad7021e81f4ba79fb8ae7f169b2e&fb_sig_app_id=156970644891&fb_sig=add7e8f73b1a89b31fb378fa716c1b4d

The code for the start.php file:

<?php
header('P3P: CP="CAO PSA OUR"');


require_once('facebook/facebook.php');

$appapikey = 'key';
$appsecret = 'key';

$facebook = new Facebook($appapikey,$appsecret);
session_start();
if(!isset($_SESSION['fbuser']))
$_SESSION['fbuser'] = $facebook->require_login(); /*forces user to be logged into facebook.com*/
else
$_SESSION['fbuser'] = $facebook->require_login(); /*forces user to be logged into facebook.com*/

?>

<html>
<head>
<title>mysite!</title>
<body style="background-color:#B0C4DE;">


<script language="JavaScript" type="text/javascript">
//Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest(); //Not IE
} else if(window.ActiveXObject) {
return new ActiveXObject("Microsoft.XMLHTTP"); //IE
} else {
//Display your error message here.
//and inform the user they might want to upgrade
//their browser.
alert("Your browser doesn't support the XmlHttpRequest object. Better upgrade to Firefox.");
}
}
//Get our browser specific XmlHttpRequest object.
var receiveReq = getXmlHttpRequestObject();
//Initiate the asyncronous request

function sayHello() {
//If our XmlHttpRequest object is not in the middle of a request, start the new asyncronous call.
if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
//Setup the connection as a GET call to SayHello.html.
//True explicity sets the request to asyncronous (default).
receiveReq.open("GET", 'index.php', true);
//Set the function that will be called when the XmlHttpRequest objects state changes.
receiveReq.onreadystatechange = handleSayHello;
//Make the actual request.
receiveReq.send(null);

}
}

//Called every time our XmlHttpRequest objects state changes.
function handleSayHello() {
//Check to see if the XmlHttpRequests state is finished.
if (receiveReq.readyState == 4) {
//Set the contents of our span element to the result of the asyncronous call.
document.getElementById('span_result').innerHTML = receiveReq.responseText;
}
}
function openMenu(query) {

var myString = 'query.php?' + query;
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}

// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
document.myForm.time.value = ajaxRequest.responseText;
}
}


ajaxRequest.open("GET", myString, true);
ajaxRequest.send(null);
pausecomp(500);
sayHello();
}


function pausecomp(millis)
{
var date = new Date();
var curDate = null;
do { curDate = new Date(); }
while(curDate-date < millis);
}




</script>
<!-- Note: Include this div markup as a workaround for a known bug in this release on IE where you may get a "operation aborted" error -->
<div id="FB_HiddenIFrameContainer" style="display:none; position:absolute; left:-100px; top:-100px; width:0px; height: 0px;"></div>
</head>

<!-- used to display the results of the asyncronous request -->
<span id="span_result"></span>
<body onLoad="sayHello();">

<BODY>
<div id="FB_HiddenIFrameContainer" style="display:none; position:absolute; left:-100px; top:-100px; width:0px; height: 0px;"></div>
<script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">
FB_RequireFeatures(["CanvasUtil"], function()
{
//You can optionally enable extra debugging logging in Facebook JavaScript client
FB.FBDebug.isEnabled = true;
FB.FBDebug.logLevel = 4;
FB.XdComm.Server.init( 'xd_receiver.htm' ) //FB.init( 'xd_receiver.htm' ); //FB.XdComm.Server.init( 'xd_receiver.htm' ); also tried this
FB.CanvasClient.startTimerToSizeToContent();
});
</script>

</BODY>
</html>

A1ien51
12-01-2009, 05:28 AM
The error message tells you what is the metter, it is not there. There is no form on your page and there is no element named time in that form.

Eric

polexian
12-01-2009, 12:36 PM
function openMenu(query) {

var myString = 'query.php?' + query;
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}

// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
document.myForm.time.value = ajaxRequest.responseText;
}
}


ajaxRequest.open("GET", myString, true);
ajaxRequest.send(null);
pausecomp(500);
sayHello();
}


I thought this was where the error was pointing me, but I can't find out what to do to fix it. Or have I mistaken?

A1ien51
12-01-2009, 02:05 PM
again, you have no form and no element time on the page. How is document.myform.time supposed to be referenced if it does not exist?

Eric

polexian
12-01-2009, 06:57 PM
Ok, so how do I reference it so I can send date through AJAX to a file to update my table without showing the user what I am doing?