/    Sign up×
Community /Pin to ProfileBookmark

beginner: why does my function not called?

hi,

im trying to get this piece of script work –
thats the relevant piece of html:

[CODE]<a href=”#” onclick=”showfilm(“antoine_doinel.html”); ”

class=”film_menu”>Antoine Doinel</a>[/CODE]

and thats the js function:

[CODE]function showfilm(kinofile) {
alert(“function was called”);
try{
var oxmlhttp = new XMLHttpRequest();
}
catch (error)
{
try{
var oxmlhttp = new ActiveXObject (“Microsoft.XMLHTTP”);
}
catch (error){
return false;
}
}
oxmlhttp.open(“GET”, kinofile, true);
oxmlhttp.send(null);
document.getElementById(“texts”).innerHTML = oxmlhttp.responseText;
}[/CODE]

i only started to write it, and im new to js, so i dont think the function works,
i just dont understand why i dont see the alert at all…?? ? ?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@boskoMay 04.2007 — [CODE]<a href="#" onclick="showfilm([COLOR="Red"]'[/COLOR]antoine_doinel.html[COLOR="Red"]'[/COLOR]); [COLOR="Red"]return false;[/COLOR]"

class="film_menu">Antoine Doinel</a>[/CODE]
Copy linkTweet thisAlerts:
@gilyotinaauthorMay 04.2007 — thanks, it works now (function gets called, at least ? )
Copy linkTweet thisAlerts:
@felgallMay 05.2007 — You need to set up a response method to handle the processing once the call returns the response which will probably be long after the initial code has finished running. The following line needs to be in that code rather than where you have it.

document.getElementById("texts").innerHTML = oxmlhttp.responseText;
Copy linkTweet thisAlerts:
@gilyotinaauthorMay 05.2007 — You need to set up a response method to handle the processing once the call returns the response which will probably be long after the initial code has finished running. [/QUOTE]

thanks, but i dont understand what should actualy come in my code, once i have the object that contains the content of the external file (kinotext).

I though i just send this content...? which method should i use??


the behavior in FF is weird: it will not put the text in the alert box at the end, but it will place it in the parent of the div i wanted it to go to.

IE7 just wont show the second alert, nor show the text.
Copy linkTweet thisAlerts:
@JMRKERMay 05.2007 — I think the following:
[code=php]
<a href="#" onclick="showfilm("antoine_doinel.html"); " class="film_menu">Antoine Doinel</a>
[/code]

should be:
[code=php]
<a href="#" onclick="showfilm('antoine_doinel.html')" class="film_menu">Antoine Doinel</a>
[/code]

to even start to work at all.
Copy linkTweet thisAlerts:
@gilyotinaauthorMay 05.2007 — yes, i changed already to

'antoine_doinel.html'

and added

return false;

and then it acted like i said, with the weird behavior of FF and IE7.
×

Success!

Help @gilyotina 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.20,
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,
)...