Link to home
Start Free TrialLog in
Avatar of henderxe
henderxe

asked on

How to determine if Javascript/Jquery is not working?

Hello:

     I upgraded from Coldfusion 9 to Coldfusion 11, and it appears that Javascript/Jquery are no longer working, especially when making calls to databases.

    I'm trying to determine which version I have, as well as the best way to upgrade, if applicable.

    Please let me know what you would need to see (e.g. files, etc.) to make an assessment.

     Thanks, and regards!
Avatar of Kim Walker
Kim Walker
Flag of United States of America image

Javascript is embedded in the user's browser, so it is always working unless the user disables it. jQuery, however, requires a library to be loaded with the page. Did the upgrade somehow change the contents of your page head? Can you post a link to a page this isn't working?
Avatar of henderxe
henderxe

ASKER

By the way, I get the following error from Javascript/Jquery:

  "unreachable code after return statement"

  Thanks!
Sorry - posted my last message before I saw your response.

To access the site requires a username, and password.

 Did you have something specific in mind in terms of a link?
Kim:

   Also, thank you for your quick response.

    Attached is the main file for the application.  Hoping this can help.
maintemp.txt
"unreachable code after return statement": That's not generally an error that will break anything, it is just warning that there is code written after a return statement which will never be executed, e.g.
function do_nothing(){
  return;
  var answer = 35 * 36;
}

Open in new window

The last line of the function is "unreachable" because the line before it will always exit the function.
I would need to see the code that's generated by ColdFusion. I'm actually surprised to hear there is an update for ColdFusion. I thought it had gone the way of XHTML.

For the record, javascript/jQuery rarely makes a call to a database. There's a third party involved. Javascript/jQuery makes a call to a script on a backend server that fetches data from a database and hands if off to the javascript/jQuery request. Although the backend script could be javascript, it is rare. Most often it is a php or asp script. In your case it could be a ColdFusion script that is handing off the data.

Is there a page which doesn't have confidential information that you could load on your browser, save the source code, and upload here? Then we can see if any errors are being generated that would help us determine the problem.
Did you make any other changes when you updated ColdFusion? Such as change the domain name?
William:

   Thanks for your comments.  Good to know that I can rule out that error!

Kim:

    As you suggested, I have uploaded the source code at the point where the error occurs.  However, I should mention that the error is a bit "misleading".

   The error is occurring because a number of drop down menus, particularly those that are very large  (e.g. degrees, zip codes, college departments, etc.), are loaded into the APPLICATIONS scope.  Therefore, when users perform queries, performance is enhanced significantly, as those fields always remain in memory.  

  Below is an excerpt of how those fields are being loaded:

  ====================  BEGIN EXCERPT ==============================

  <cfcomponent name="getAppScopeDataDAO" extends="MachII.framework.Listener">
<cfset basePath = "#GetDirectoryFromPath(replace(expandPath("./"), "\","/","ALL"))#">
 <cfset baseFolder =   "#GetFileFromPath(left(basePath,len(basePath)-1))#">
        
      <cffunction name="init" access="public" output="false" returntype="ART.model.scheduled.getAppScopeDataDAO" hint="getting the database details from Listener">
         <cfargument name="dbName" type="string" required="yes" hint="dbName">
         <cfargument name="dbUserName" type="string" required="yes" hint="UserName">
         <cfargument name="dbPassword" type="string" required="yes" hint="Password">
         
                     <cfset db = StructNew() />
                        <cfset  db.dbname =dbName >  <!--- getting dbname from machii.xml  --->
                   <cfset db.dbUserName =dbUserName  >
                   <cfset  db.dbPassword = dbPassword > 
            <cfreturn this>
      </cffunction>    
   
      <cfset result="Result is None" />
      <cffunction name="newQueryAppScopeData" access="public" output="true" returntype="any" hint="Load the application variables">
          
      <cfset test = structclear(Application)><!---  Clear the structure every time load the data --->
      <cftry>       
          <!--- Select Degrees related info --->
      <cfif NOT IsDefined("APPLICATION.colleges")>  
        <cfquery name="APPLICATION.colleges"  datasource="#db.dbName#"  username="#db.dbUserName#" password="#db.dbPassword#">
             SELECT t.school_code,  t.school_code||' - '||min(t.short_desc) short_desc
            FROM advance.tms_school t,
            advance.tms_majors maj
            where t.school_code = maj.school_code and NOT t.school_code in ('99')
            group by t.school_code order by  short_desc
        </cfquery>
         </cfif>  
       
          <!---cfoutput>#APPLICATION.colleges.recordcount#</cfoutput--->
        <cfif NOT IsDefined("APPLICATION.deptCode")>  
        <cfquery name="APPLICATION.deptCode" datasource="#db.dbName#"  username="#db.dbUserName#" password="#db.dbPassword#"  >
                            select distinct
                      advance.tms_dept_code.dept_code
                ,     advance.tms_dept_code.dept_code
                ||    ' - '
                ||    advance.tms_dept_code.short_desc   short_desc
                ,     inn_tbl.coll_code                  school_code
                from
                      advance.tms_dept_code
                ,(select distinct
                      advai.art_degrees_granted.devel_school_code  coll_code
                ,     advai.art_degrees_granted.devel_dept_code  dept_code
                ,     advai.art_degrees_granted.major_code
                ,     advai.art_degrees_granted.degree_code
                ,     advai.art_degrees_granted.level_code
                   from
                      advai.art_degrees_granted
                   <!--- where
                      advai.art_degrees_granted.real_degree = 'Y' --->
                        )  inn_tbl
                where
                   not advance.tms_dept_code.dept_code = ' '
                    and not advance.tms_dept_code.short_desc = ' '
                    and advance.tms_dept_code.dept_code = inn_tbl.dept_code
        </cfquery>
        </cfif>  

  ====================  END EXCERPT ==============================

 Also, a couple of other things:

    1.  To your point about a change in domain name, I am performing the upgrade on a new (and separate) server, but accessing it, via its IP Address, rather than domain name, which will remain the same.

    2.  Also, attached are screenshots of the application.

Thank you both, your assistance is very much appreciated.
application_error.txt
application_screenshots.docx
Let me say that I know nothing about ColdFusion. But I do know javascript and jQuery. This error is being generated by the back-end – the server running ColdFusion. Javascript and jQuery are front-end scripting languages – they run in the browser on the user's computer AFTER the server has delivered the page. I am confident that this is NOT a javascript/jQuery issue unless ColdFusion is running in javascript on the backend (which is possible but highly unlikely).

I am performing the upgrade on a new (and separate) server
So, technically, you're building a new server with upgraded software. Right? Have you migrated the databases from the original server to the new server? (Again, I know nothing about ColdFusion so I'm speaking in general terms here.)

You may need to request the administrator to add ColdFusion to the tags so some ColdFusion experts can pipe in on this question. Or he may suggest that you repost the question under ColdFusion.
Kim:

    Totally understand your analysis, and it's clear that I should have included Coldfusion in the mix.

    Yes, it is a completely new server upgraded to Coldfusion 11, but the application (from old server), as well as the databases were successfully migrated to the new server -  moved them myself.

     Admittedly, my knowledge of  Javascript/iQuery is not that far from the basics, but my rationale for assuming that they were the culprits follow:

    1.  Most of the database calls in this application are made, via AJAX, and if it fails (e.g. due to a database issue), then the error points to Coldfusion, but it's not actually a Coldfusion issue.   It has happened a few times in the past.

    2.   I have some familiarity with Firebug, and when data is returned (via JSON format), I see something like in the the attached file, which confirms that the data request succeeded.   I don't see any of that in Firebug on the new server, other than the message I posted at the beginning:
       ("unreachable code after return statement").

    So, the absence of activity in Firebug, as before, in part, led me to believe that perhaps Javascript/jQquery was not working, and thus needed to be upgraded.  

     Anyway, your point is well taken.  As a minimum, I need to involve the Coldfusion folks.

     I'm very sorry for the confusion, and will communicate with the Administrator to move to the appropriate forum.

     But please know that I am very grateful for your  assistance - many thanks!

     Kind  regards,

   


     

      1.
firebug_results.docx
This is now a completely different issue.

The firebug results are a clear indication that these javascript and jQuery files could not be found on the server at that URL. If these files are not found, then the javascript and jQuery scripts would be absent. Not only are they not working, they are completely absent because they couldn't be found.

Does the computer which you are viewing the page with have access to the art.uadv.msu.edu server? Is art.uadv.msu.edu the new server? You said earlier that you are accessing the new server via IP address, not domain name. If you have the new server on a local network only, then the computer you use to view the HTML page on must have access to both the local network and the internet unless art.uadv.msu.edu is the new server in which case there must be a domain name server in the local network to resolve the url or you must modify the hosts file on the viewing computer.
Kim:

  The new server is on the same domain as the old server (e.g.  uadv.msu.edu), and does have access to the old server. We have our own DNS server.

   I also added the IP address, and domain name of the old server to the new server in the hosts file, but am still unable to make it work.  

    The application was copied over from the old server, and no changes were made.  So, the file structure is exactly the same.

      What you're suggesting makes perfect sense, so I'm wondering if there a way I can test to ensure that it Javascript/jQuery are indeed working by manipulating the path on the new server?

     I could also test by switching the domain name from the old server to the new, but that requires requesting a DNS change which may take a day, or so, and if it doesn't work, another day, or so to switch it back, thus affecting users.

    Thanks!
I should have looked closer at the screen capture you provided. In that firebug capture there are four files that could not be located. Two of those are javascript files and two are css files. However, there is a fifth file that it was able to locate on the same server. So communications with the server is not the issue. I apologize for going down that bunny trail.

The fifth file that it is able to locate is almost the same path as the four it couldn't. The difference is the fifth file is in a subfolder named cfm. Is it possible that the four missing files are also in the cfm subfolder on the new server? Is art.uadv.msu.edu the new server or the old one?
Kim:

   The Firebug screenshot I sent is from the current server, which works fine.  The missing files you see are truly missing, but the code hasn't been cleaned up to remove those entries.  It was an example of what I did see, especially the return of data, via JSON, on the existing server.

    I don't get any of that on the new server (see attached file), other than the error I mentioned.  Note the files on the right in the screenshot (e.g.  main.js)  This file is MAJOR , and contains many functions for AJAX calls, and other Javascript/jquery functionality.

   But, on the new server, it does nothing at all!

    The domain, art.uadv.msu.edu is currently on the old server, but will be transferred to the new server once it is completed.
I'd still like to see the source code to see what's going on, but if the new server is not on the internet, it wouldn't do me much good. HOWEVER, how are you linking to the jQuery library? Do you have it stored locally or are you loading it from a CDN and does the new server have access to the CDN?
Kim:

   The new server is on the internet, and the jQuery library is stored locally (not CDN).

     I've never used CDN before,  but, I can switch to it if that helps.

    Also, I can provide additional source code, but not sure exactly which portion of the application I should run to obtain it.  The last source code I sent was up to the point where I received an error, and the the program stopped.  

    But that was one of the features of the application, although a huge one.  Do you have something else in mind?
Kim:

   The new server is on the internet, and the jQuery library is stored locally (not CDN).

     I've never used CDN before,  but, I can switch to it if that helps.

    Also, I can provide additional source code, but not sure exactly which portion of the application I should run to obtain it.  The last source code I sent was up to the point where I received an error, and the the program stopped.  

    But that was one of the features of the application, although a huge one.  Do you have something else in mind?
Actually, you've only sent native code. I need the source code that is the result of running your native code. If your new server is on the internet, perhaps I can see what's going on. Just load a page in your browser that produces the error and press control-u (view source). Save the source code into a .txt or .html page and attach that to a comment. I may be able to reproduce the error from the source code to see what's going on. But then again, I may need an authorized session before I can reproduce it.
Kim:

   Two files are attached!

   One after just logging in (source_code_login_only.txt), and the other after encountering the error (source_code_error.txt).

  Thanks!
source_code_error.txt
source_code_login_only.txt
ASKER CERTIFIED SOLUTION
Avatar of Kim Walker
Kim Walker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Kim:

  Sorry for the delay  .  .   .  had to address another issue!

   To answer your questions:

        1.  Yes, there "should" be a table called APPLICATION.membershipGroup if the code that uploads this data to the server was working correctly, which follows:

  <cfif NOT IsDefined("APPLICATION.memberGroup")>  
        <cfquery name="APPLICATION.memberGroup"  datasource="#db.dbName#"  username="#db.dbUserName#" password="#db.dbPassword#">
             SELECT t.school_code,  t.school_code||' - '||min(t.short_desc) short_desc
            FROM advance.tms_school t,
            advance.tms_majors maj
            where t.school_code = maj.school_code and NOT t.school_code in ('99')
            group by t.school_code order by  short_desc
        </cfquery>               
         </cfif>  

  The above query loads the fields (APPLICATION.membershipGroup, ) into the APPLICATIONS scope (or memory), as well as and a lot of others. They're loaded automatically when the server starts, or is re-booted.  For whaterever reason, they're not loading.

    2.  Yes - the clientid is correct!

    What's happening is that it is not loading, and the error you see is because another query is looking for the APPLICATION.colleges (or any one of them), and it has not been uploaded to memory.

    But, your analysis is on target in terms of this not being a Javascript/jQuery issue, and was very helpful in keeping my focus on Coldfusion, because I surely thought it was jQuery.

    Anyway, I regret wasting you time, and since you're not involved with Coldfusion, I'd like to give you full credit for this question, and re-post it under a Coldfusion Tag.  

    Actually, I did request from the Administrator that a Coldfusion Tag be added to this question, and it was added, but I think I've added too much confusion to this post. So, I will re-post the question

  Just wanted to make sure I answered your questions!

    Thank and regards,
I'm glad I was at least helpful. I hope you have good luck with a ColdFusion expert.