/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Problem appending a script in Firefox

Hello all,

I’ve searched the forum and google but not found an answer to my problem. The below code executes fine in Internet Explorer but Firefox is unable to find the array that should have been created:

[CODE]
url = “test.php”

var headtag = document.getElementsByTagName(‘head’)[0];
var script= document.createElement(‘script’);
script.type = ‘text/javascript’;
script.src = url;
headtag.appendChild(script);[/CODE]

test.php runs a database query which echos out the following:

[CODE]
calendarArray = new Array();
calendarArray[0] = new Array(“10″,”01022010″,”Test Event”,”allDay”,”none”,”once”,”none”);
calendarArray[1] = new Array(“11″,”04022010″,”Test Event2″,”1300″,”Event Description 2″,”yearly”,”1900″);[/CODE]

When I try to access the array in firefox, I get a calendarArray is not defined error.

Any help would be appreciated.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@asparagus_timeauthorFeb 12.2010 — I fixed it myself.

I added the below to the end of my code snippet

[CODE]script.onload = function {

// the rest of my original function here
}

[/CODE]


and now it works like a charm. Anyone know why IE can process it without but firefox can't? Is it just speed of parsing the new script tag?
×

Success!

Help @asparagus_time spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...