Function works and then says not defined



I have some code to dynamically retrieve one of three AJAX files and insert it into a DIV The Javascript is function createajax() { var Ajax; try{ Ajax = new XMLHttpRequest(); } catch (e){ try{ Ajax = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ Ajax = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ alert("Error!!!"); return false; } } } return Ajax; } function basicAjaxSwitch(File, Recipient, Animate) { if ( Animate == true ) { Animation(document.getElementById(Recipient)).duration(100).from('opacity', 1).to('opacity', 0).go(); } basicAjaxSwitch = createajax(); basicAjaxSwitch.onreadystatechange = function(){ if(basicAjaxSwitch.readyState == 4){ if ( Animate == true ) { Animation(document.getElementById(Recipient)).duration(100).checkpoint().duration(100).from('opacity', 0).to('opacity', 1).go(); setTimeout('document.getElementById("'+Recipient+'").innerHTML = basicAjaxSwitch.responseText;', 100); } else { document.getElementById(Recipient).innerHTML = basicAjaxSwitch.responseText; } } } basicAjaxSwitch.open("GET", "/ajax/"+File, true); basicAjaxSwitch.send(null); } function changesidebarinfo(changeto) { if ( changeto == 'login' ) { Animation(document.getElementById('main_layout_accountlinks_background')).to('left', '0px').duration(100).go(); Animation(document.getElementById('main_layout_accountlinks_login')).duration(100).to('color', '#FFF').go(); Animation(document.getElementById('main_layout_accountlinks_signup')).duration(100).to('color', '#000').go(); Animation(document.getElementById('main_layout_accountlinks_about')).duration(100).to('color', '#000').go(); basicAjaxSwitch('contentinfo/login.php', 'main_layout_rsbinfo_container', true); } else if ( changeto == 'join' ) { Animation(document.getElementById('main_layout_accountlinks_background')).to('left', '50px').duration(100).go(); Animation(document.getElementById('main_layout_accountlinks_login')).duration(100).to('color', '#000').go(); Animation(document.getElementById('main_layout_accountlinks_signup')).duration(100).to('color', '#FFF').go(); Animation(document.getElementById('main_layout_accountlinks_about')).duration(100).to('color', '#000').go(); basicAjaxSwitch('contentinfo/join.php', 'main_layout_rsbinfo_container', true); } else if ( changeto == 'about' ) { Animation(document.getElementById('main_layout_accountlinks_background')).to('left', '100px').duration(100).go(); Animation(document.getElementById('main_layout_accountlinks_login')).duration(100).to('color', '#000').go(); Animation(document.getElementById('main_layout_accountlinks_signup')).duration(100).to('color', '#000').go(); Animation(document.getElementById('main_layout_accountlinks_about')).duration(100).to('color', '#FFF').go(); basicAjaxSwitch('contentinfo/about.php', 'main_layout_rsbinfo_container', true); } }
And the HTML that triggers the actions is   Log In Join About
When I click one of the 3 buttons (doesn't matter which) the result is exactly as intended. Then when I click another (or the same) button, nothing happens and Firebug gives the error basicAjaxSwitch is not a function changesidebarinfo("login")site.js (line 61) function onclick(event) { changesidebarinfo("login"); }(click clientX=816, clientY=41)2 (line 2) [Break on this error] basicAjaxSwitch('contentinfo/login.php...'main_layout_rsbinfo_container', true);\n
Posted On: Friday 16th of November 2012 02:54:12 AM Total Views:  172
View Complete with Replies

RELATED TOPICS OF JavaScript PROGRAMMING LANGUAGE




Two functions on one ID

When I execute my functions the first one works fine and the second is called because I get my alert box but the second function does not execute. Any ideas why Any input is appreciated. function changeFont() { document.getElementById("q4").style.fontStyle ="italic"; } function changeFontBack() { alert("changeFontBack function"); document.getElementById("q4").style.fontStyle="normal"; } 5. Part 1. Mouseover this paragraph to change the font to a font of you choice. Part 2. Click on this paragraph to return the font to the default font. }[/CODE]
VIEWS ON THIS POST

247

Posted on:

Friday 16th November 2012
View Replies!

Setting cookie for toggle function

I would really appreciate some help with this. I have searched and searched the internet but cannot find information on exactly what I am trying to do. I have a javascript toggle function: function toggle_change() { var ele = document.getElementById("change_log"); var text = document.getElementById("Toggle_change"); if(ele.style.display == "none") { ele.style.display = "block"; text.innerHTML = "-"; } else { ele.style.display = "none"; text.innerHTML = "+"; } } What I am trying to do is set a cookie that will remember if the display status is "none". This is probably something simple but I don't know much about javascript obviously. I've tried a few different approaches but I can never get the script to actually set a cookie.
VIEWS ON THIS POST

97

Posted on:

Friday 16th November 2012
View Replies!

Client side Javascript function does not work in server?

Hi all I have javascript function that insert text into freetextbox at current cursor position. It works well when I call this function onClientClick event passing a string as a parameter (This string is inserted into freetextbox at current cursor position). My code is as follow
VIEWS ON THIS POST

204

Posted on:

Friday 16th November 2012
View Replies!

using xmlHTTP.responseText in any other java function

is it possible to use the xmlHTTP.responseText in any other java function, after execuation of stateChanged() function\t example in ajax... function stateChanged(){ if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { var result = xmlHttp.responseText if (result.length=="0"){ var task = "do"; //i want to use "task" in other js function return task; } } } i used many ways (a little bit i know) to do but could not get the success. how can we do\t any thoughts please......
VIEWS ON THIS POST

88

Posted on:

Friday 16th November 2012
View Replies!

javascript function issue

Your function prints the variable passed to it, and you pass it the value of doc.Documents("C:\\Users\\vinay\\Desktop\\HTMLPages\\test\\pr.txt").Content; I would imagine that's returning a null or undef value. Also, be careful with document.write in the head, best to use innerHTML to set content of existing elements. :)
VIEWS ON THIS POST

86

Posted on:

Friday 16th November 2012
View Replies!

Date function in Drop-Down Box

, try this code("Function") this may help you JavaScript: // //]]> HTML create Option Select Date But if you like to to capture current date, then you can use Text Box, i think there is not any need of multiple selections for current date... Function for Text BoxJavaScript: // //]]> HTML create Option I Hope this will help you Best
VIEWS ON THIS POST

67

Posted on:

Friday 16th November 2012
View Replies!

js math function help

Iam making a game, the error is that in the "d" loop (for...) the value "holeBalls" stays always the same. for (d=holeNum;d
VIEWS ON THIS POST

203

Posted on:

Friday 16th November 2012
View Replies!

Which function to use for inserting string on a timer?

I'm learning javascript. My first idea has led to a problem. I'm trying to set up strings to load at random intervals on different parts of the page, but I don't know the right function to use with setTimeout(). I hear "don't use document.write" and "probably don't use innerHTML", but are other functions outside of javascript Please help.
VIEWS ON THIS POST

162

Posted on:

Friday 16th November 2012
View Replies!

using if condition & functions in JS

student details student name father's name coursemca mba btech ba male female address subject1 subject2 subject3 subject4 subject5 total grade
VIEWS ON THIS POST

113

Posted on:

Friday 16th November 2012
View Replies!

AJAX functions using Jquery

Hi , I'm using jquery in this piece of script and also trying to call the functions. But, they aren't working at ALL and the firefug is saying that there is an error in the script. The error is missing ) in parenthetical [Break On This Error] $.post('ajax/like_add.php', (article_id:article_id), function(data){ and the firebug points to the colon. This is the entire piece of script that has both functions. function like_add(article_id){ $.post('ajax/like_add.php', (article_id:article_id), function(data){ if(data == 'success'){ like_get(article_id); }else{ alert(data); } }); } function like_get(article_id){ $.post('ajax/like_get.php',(article_id:article_id), function(data){ $('#article_'+article_id+'_likes').text(data); }); }
VIEWS ON THIS POST

142

Posted on:

Monday 19th November 2012
View Replies!

Accessing a variable outside of a javascript function?

I thought of a dirty hack but Im not sure if it is possible Make a blank alert appear and then disppear. This would remove the alert from being shown and would make this finally work.
VIEWS ON THIS POST

92

Posted on:

Monday 19th November 2012
View Replies!

Pass id of anchor to use in function: JQUERY

, I was wondering if someone could help me with this. I want to, when an anchor link is clicked, the id of the link is grabbed by jquery then passed to a function. The id is would be the same as the id of the div that is used for the function (highlight). If someone could tell me or point me in the right direction. Here is what I have right now. $(function(){ $('#mainq a').click(function(){ var id = this.id(); $('this.id').highlightFade({speed:2000}); }); }); The HTML is like this (its for FAQ section): QUESTIONS SECTION: Payment and Billing. What is water What is copper Payment and Billing. What is water What is copper ANSWERS HERE: What is Water Water is H2O. What is Copper Copper is cu. The code is a little messy but I am just testing right now. So if someone clicks on #aq1 link the id "aq1" is grabbed and used for the highlightFade function. It would highlight the div with id "aq1".
VIEWS ON THIS POST

91

Posted on:

Monday 19th November 2012
View Replies!

Two Ajax functions on same DIV problem

I have two Ajax function that are on the same div, so the first one isn't executed or better is canceled from the second one. Any hint on how to fix this problem I wasted two days and wasted my brain too without finding a solution. $(function(){ $('#navigation').find('a').tooltip({effect: 'slide'}); }); $(window).load(function(){ $('#sliding').slider({ _Options: { imageWidth: 300, imageHeight: 200 } }); }); function swapContent(cv) { var url = "testing_cover.php"; $.post(url, {contentVar: cv}, function(data) { $("#sliding").html(data).show(); }); }
VIEWS ON THIS POST

106

Posted on:

Monday 19th November 2012
View Replies!

Stop one function with another OR call function()->Function()

Question it title, how to do it I need to stop a function with another function or I need to call a global function inner function with another global function so I could stop it that way. I know its possible but how
VIEWS ON THIS POST

114

Posted on:

Monday 19th November 2012
View Replies!

issue when calling php code from a function

all . I use this code roughly to call some php code then run it in an html container. function getVote(int) { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("boxcenter").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","poll_vote.phpvote="+int,true); xmlhttp.send(); } It works well although everytime i use this function in anyway it takes me back to the top of the page everytime. Does anyone know of a way to just keep people in one place on my page when i use this function.
VIEWS ON THIS POST

186

Posted on:

Monday 19th November 2012
View Replies!

call java function in script

I want to call java function in javascript. In which we pass one parameter to function and its returns String value which I want to display in alert message. So please help me.....
VIEWS ON THIS POST

85

Posted on:

Monday 19th November 2012
View Replies!

help with javascript if function

, I have script that sums all textboxes value from dynamically added row, but still i have problem with the script. below listed two version of script /*
VIEWS ON THIS POST

129

Posted on:

Monday 19th November 2012
View Replies!

One function to toggle multiple divs

I will have a page with about a 100 or so different links and I would like each one to toggle the visibility of its corresponding hidden div. For instance, if I have a county 'Johnson' when it's clicked I would like the hidden div associated with that county to become visible. I would like to do this without having to write a different function for each one. Is there a way to do this easily Below is a solution I was given elsewhere but I couldn't get it to work. Most ideal of all I would like it to work with an image map, with each county having it's own set of stats to be toggled in.
VIEWS ON THIS POST

164

Posted on:

Monday 19th November 2012
View Replies!

Calling 2 AJAX functions

there DaniWeb, Recently i found out that there was a thing that didn't work in my CMS. Code (index.php): (in a PHP file) Issue: It calls the loadManageNews() function just finse but it doesn't call the loadManageNav(). It also loads the loadMCE() function just fine. And yes there is a function named loadManageNav() and the ajax.js file is included. Code (ajax.js): function refresh() { window.location = 'index.php'; } function update() { document.getElementById("answer").innerHTML=""; if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { setTimeout('refresh()',1000); document.getElementById("answer").innerHTML=xmlhttp.responseText; } } xmlhttp.open("POST","./process/update.php",true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send("version=" + document.getElementById("version").value + "&version1=" + document.getElementById("version1").value); } function loadManageNews() { document.getElementById("manage").innerHTML='Loading...'; if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); xmlhttp.open("GET","./process/managen.php",false); xmlhttp.send(null); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp.open("GET",url,false); xmlhttp.send(); } document.getElementById("manage").innerHTML=xmlhttp.responseText; xmlhttp = null; } function loadManageNav() { document.getElementById("managenav").innerHTML='Loading...'; if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); xmlhttp.open("GET","./process/managenav.php",false); xmlhttp.send(null); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp.open("GET",url,false); xmlhttp.send(); } document.getElementById("managenav").innerHTML=xmlhttp.responseText; xmlhttp = null; } function delNews(id) { confirm = confirm("You are just about to delete the news post with id " + id + "."); if(confirm) { if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { wackoo("./process/managen.php","manage"); } } xmlhttp.open("GET","./process/deleten.phpid=" + id,true); xmlhttp.send(); } else { } delete confirm; } there you go... and yes the ./process/managenav.php file exists and it outputs just fine if i go to the file alone. Please help.
VIEWS ON THIS POST

73

Posted on:

Monday 19th November 2012
View Replies!

Executing a function on page load ?

Test Page: http://www.eojmarket.com/index.phppag=26 Code below: Question: Is it possible to get rid of the button and have it scroll to 0,265 on page load Comment: doesn't appear to work.
VIEWS ON THIS POST

85

Posted on:

Monday 19th November 2012
View Replies!