Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Javascript changes not seen

  • 28-12-2013 01:43PM
    #1
    Closed Accounts Posts: 6,075 ✭✭✭


    I have a jsp file that calls a javascript function in a separate .js file. I have made an amendment to the .js function (added an alert()) and re-run the program. The alert is not called therefore the method is not called. I have renamed the method so that I get an exception but the method is successfully called. I have cleared the cache on Chrome and nothing has changed. I am using IntelliJ + embedded Tomcat.

    Can anyone tell me what is going wrong? I


Comments

  • Registered Users, Registered Users 2 Posts: 2,021 ✭✭✭ChRoMe


    I have a jsp file that calls a javascript function in a separate .js file. I have made an amendment to the .js function (added an alert()) and re-run the program. The alert is not called therefore the method is not called. I have renamed the method so that I get an exception but the method is successfully called. I have cleared the cache on Chrome and nothing has changed. I am using IntelliJ + embedded Tomcat.

    Can anyone tell me what is going wrong? I

    Can you post some code?

    Is firebug reporting any exceptions?


  • Closed Accounts Posts: 6,075 ✭✭✭IamtheWalrus


    ChRoMe wrote: »
    Can you post some code?

    Is firebug reporting any exceptions?

    I don't see any exceptions in Firebug..
    <div id="names" style="width: 100%;"><script>writePax();</script></div>
    
    function writePax(asString) {
        //NOT IT!!!!
        alert(gRoomCots[1])  ;
    	var s=gHdr;
    	var roomAge,isChild,optNew;
    	for (var i=0; i<gBerths.length; i++) {
    		s+='<TR><TD>'+gBerths[i]+'</TD><TD>&nbsp;</TD><TD width=200>';
    		isChild=gRoomAges[i]!=0;
    		if (gAsgnId[i]<0) {
    			s+='<INPUT CLASS=tableInput TYPE=TEXT NAME=newName'+i+' maxlength=52 size=25 onKeyPress="return editKey(event,gMask1);">';
    			optNew=' CHECKED';
    		} else {
    			s+=gNameSwap+','+i+')" NAME=paxName' + i + (gDisabled?' disabled':' ') + '>'+(isChild?gChildList:gPaxList);
    			optNew=' ';
    		}
    		s+='</TD><TD align=center nowrap>';
    		s+='<input type="radio"' + (gDisableLeadRadio? ' disabled' : '') + ' name="lead" value="'+i+'" tabindex="'+(100+2*i)+'"'+' >';
    		s+='</TD><TD align=justify nowrap>';
    		if(!isChild && gAsgnId[i]<0) {
    			s+='<div id="adultChildRadio'+i+'">'
    			  +'<input type="radio" name=adult'+i+' value="A" onClick="testAges(this,'+i+',false);" checked tabindex="'+(100+2*i)+'">'+gAdultTxt
    			  +'&nbsp;&nbsp;&nbsp;'
    			  +'<input type="radio" name=adult'+i+' value="C" onClick="testAges(this,'+i+',true);" tabindex="'+(100+2*i+1)+'">'+gChildTxt
    			  +'</div>';
    		}
    		s+='</TD><TD align=center width=10%>&nbsp;';
    		if (isChild) {
    			s+=gRoomAges[i];
    			gNewAges[i]=gRoomAges[i];
    		} else {
    			if (gAsgnId[i]<0) {
    				s+='<SELECT NAME=ages'+i+' id=ages'+i+' style="visibility:hidden;">'+gChildAgeList;
    			} else {
    				var chAge=gPaxAges[gAsgnId[i]];
    				s+=(chAge>0)?chAge:'&nbsp;';
    			}
    		}
    		s+='</TD><TD align=center>';
    		if (gIsNewBkg || !gFullView || gDisabled) {
    			s+='&nbsp;';
    		} else {
    			s+='<INPUT CLASS=tableInput onClick="flipType(this.form,'+i+')" TYPE=checkbox NAME=newPax'+i+optNew+'>';
    		}
    		s+='</TD></TR>"dddd"<script>testAgeLabel();</script>';
    	}
    
    	s+=gHdrEnd;
    
    	if(!asString){
    		document.writeln(s);
    	}
    	return s;
    }
    


  • Registered Users, Registered Users 2 Posts: 9,373 ✭✭✭Phoebas


    Is it possible that there is an old copy of the javascript file cached in your browser cache?


  • Closed Accounts Posts: 6,075 ✭✭✭IamtheWalrus


    Phoebas wrote: »
    Is it possible that there is an old copy of the javascript file cached in your browser cache?

    It has to be something like that but I have cleared my cache.. I'm at this for days now..


  • Closed Accounts Posts: 6,075 ✭✭✭IamtheWalrus


    I've deleted the file that writePax resides and the method is still being called (i.e. I can see the method's output on screen). Something is wrong here.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 9,373 ✭✭✭Phoebas


    I've deleted the file that writePax resides and the method is still being called (i.e. I can see the method's output on screen). Something is wrong here.

    Sounds like a cache issue. Can you see the javascript in the browser and put a breakpoint in it? Or try a different browser?


  • Registered Users, Registered Users 2 Posts: 2,021 ✭✭✭ChRoMe


    I've deleted the file that writePax resides and the method is still being called (i.e. I can see the method's output on screen). Something is wrong here.

    Do a search for all instances of that method signature in your codebase, if you have truly cleared the cache, then that has to be the explanation.


  • Closed Accounts Posts: 6,075 ✭✭✭IamtheWalrus


    ChRoMe wrote: »
    Do a search for all instances of that method signature in your codebase, if you have truly cleared the cache, then that has to be the explanation.

    I have search for writePax in the entire code base. There are 10. I have renamed every one of them to something else yet the function is still called.


  • Registered Users, Registered Users 2 Posts: 11,090 ✭✭✭✭28064212


    Open Firebug, go to Console, call your function from the command line with an invalid parameter, and it will tell you the file and line-number where the exception is raised

    Boardsie Enhancement Suite - a browser extension to make using Boards on desktop a better experience (includes full-width display, keyboard shortcuts, dark mode, and more). Now available through your browser's extension store.

    Firefox: https://addons.mozilla.org/addon/boardsie-enhancement-suite/

    Chrome/Edge/Opera: https://chromewebstore.google.com/detail/boardsie-enhancement-suit/bbgnmnfagihoohjkofdnofcfmkpdmmce



  • Closed Accounts Posts: 6,075 ✭✭✭IamtheWalrus


    28064212 wrote: »
    Open Firebug, go to Console, call your function from the command line with an invalid parameter, and it will tell you the file and line-number where the exception is raised

    ReferenceError: writePax is not defined

    BUT, how come the output of the function is on my screen?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 11,090 ✭✭✭✭28064212


    ReferenceError: writePax is not defined

    BUT, how come the output of the function is on my screen?
    If you look at the HTML source of the page (using Ctrl+U, NOT using Firebug) is the output shown there?

    Boardsie Enhancement Suite - a browser extension to make using Boards on desktop a better experience (includes full-width display, keyboard shortcuts, dark mode, and more). Now available through your browser's extension store.

    Firefox: https://addons.mozilla.org/addon/boardsie-enhancement-suite/

    Chrome/Edge/Opera: https://chromewebstore.google.com/detail/boardsie-enhancement-suit/bbgnmnfagihoohjkofdnofcfmkpdmmce



  • Closed Accounts Posts: 6,075 ✭✭✭IamtheWalrus


    28064212 wrote: »
    If you look at the HTML source of the page (using Ctrl+U, NOT using Firebug) is the output shown there?

    Ok, I've found the issue. Using Firebug, I can now debug into the writePax function but... there is no alert() function. So the version I have amended is not the version being used in the app - even though the version in my exploded war has the amended version (with the alert()).


  • Registered Users, Registered Users 2 Posts: 2,021 ✭✭✭ChRoMe


    Ok, I've found the issue. Using Firebug, I can now debug into the writePax function but... there is no alert() function. So the version I have amended is not the version being used in the app - even though the version in my exploded war has the amended version (with the alert()).

    Right.. what exactly was the reasoning for having ten similar method signatures?


  • Closed Accounts Posts: 6,075 ✭✭✭IamtheWalrus


    ChRoMe wrote: »
    Right.. what exactly was the reasoning for having ten similar method signatures?

    I'm working on a system written my men (or women, lest we be sexual) disguised as developers.


  • Closed Accounts Posts: 6,075 ✭✭✭IamtheWalrus


    Oh dear god, I've solved it...

    My app is using a static server to serve files and it's configured to use a static version of my .js file. I've pointed my app to use local files and it is now displaying the alert().

    I've been trying to solve this for 8 days now :mad:

    Thanks for all your help people. I am very grateful.


  • Registered Users, Registered Users 2 Posts: 2,021 ✭✭✭ChRoMe


    Oh dear god, I've solved it...

    My app is using a static server to serve files and it's configured to use a static version of my .js file. I've pointed my app to use local files and it is now displaying the alert().

    I've been trying to solve this for 8 days now :mad:

    Thanks for all your help people. I am very grateful.

    We have all been there :)

    Glad you got sorted.


  • Registered Users, Registered Users 2 Posts: 1 jukkaaakula


    I has the problem too.

    But then I made an error in javascript code. Then it did not accept the change. When I deleted the change it started to work fine.


Advertisement