Link to home
Start Free TrialLog in
Avatar of Matt Grofsky
Matt GrofskyFlag for United States of America

asked on

Coldfusion 8 Ajax and CFIDE as Virtual Folder throwing a javascript error

For some strange reason I have a website that is unable to access the CF8 Ajax scripting libraries.

The website is not set up as the default website on the server (IIS 6.0 , Windows 2003), and the the CFIDE directory is virtual folder under that website.  Everything works inculding form field validation, Flash forms and so on, the only thing that doesnt is Ajax.  CFdiv would be a good example.  I get back and error for something as simple as

<cfdiv bind="url:TestPage.cfm"></cfdiv>

The error I get back is "Error processing Javascript markup for element cf_div1195589780172: [Enable debugging by adding 'cfdebug' to your URL parameters to see more information]"

Adding ?cfdebug=1 just gave me the same error.

This code does work however under the default website.  I checked security settings for the virtual directory and there is read and script access to the entire directory, so not sure what else I should be looking at to get this working.

Avatar of Scott Bennett
Scott Bennett
Flag of United States of America image

Are you certain that the CFIDE directory you have created a virtual directory to contains all of the files in the /CFIDE/Scripts/ folder? the /CFIDE/Scripts/ folder should contain 1,887 files and 250 folders. if it only has 2 files then your virtual directory is pointed to an old version of the cfide directory.
Avatar of Matt Grofsky

ASKER

hmm ok I did a check and it contains 2,954 Files and 397 Folders.

It definitely has something to do with permissions I'm just not sure what it is.

I'm fairly certain that the appropriate rights are set, but not 100% sure since its not working.

But cfform.js is working without any issue as well as all the masks so not sure.

Virtual Directory is fairly straight forward, but here is an image of what I have in the way of setup.

http://66.193.54.196/untitled-1.gif 

This is exactly mimicked from the default website where ajax doesnt' give the error.
You should leave the "Script Source Access" box unchecked. Enabling that setting gives people access to your source code which is a pretty big security risk.

Are the 2,954 Files and 397folders in the /CFIDE/Scripts folder or the whole /CFIDE/ directory. If you were just counting the Scripts folder then you have too many files in there if you are counting the whole CFIDE Directory then it looks like you have a few extra files and folders but the numbers are pretty close. I would suggest you use FireFox, Install the FireBug add on (https://addons.mozilla.org/en-US/firefox/addon/1843) and then use that to help you figure out if any particular files are missing.



Indeed, the scripts folder does have 1887 files and 250 folders so thats all good.  I was looking at the CFIDE dir before.

I went ahead and ran the page in firefox with firebug installed, but same errors.

Now I was messing arounf though and found something interesting.  The pag eI am trying to run is in a directory of the web www.domain.com/dir/

But if I move the page our of the sub directory and run it at the root it works.  I went ahead and tried fiddling with scriptsrc to see if that might be the issue  

<cfajaximport tags="cfdiv" scriptsrc="/../CFIDE/Scripts">
<cfajaximport tags="cfdiv" scriptsrc="../CFIDE/Scripts">
<cfajaximport tags="cfdiv" scriptsrc="/CFIDE/Scripts">

None worked.

Even tried creating a virtual directory CFIDE int he sub directory and that didnt work.
when you are adding ?cfdebug=1 to your url and getting the same error, do you also have debugging enabled in coldfusion administrator?

you need to check the " Enable AJAX Debug Log Window " box on the " Debugging & Logging > Debug Output Settings" page in the administrator for the ?cfdebug=1 to work properly
well I found what was causing this error, but cant seem to fix it.

It seems if I put in javascript at the top fo the page that does somethign else it interferes with the CF8 ajax.

In this case its for a dhtml menu

  <SCRIPT TYPE="text/javascript">
  var dmWorkPath="data.files/";
  </SCRIPT>

  <SCRIPT TYPE="text/javascript" SRC="data.files/dmenu.js"></SCRIPT>
ok so I know whats going on now, but have no idea why or how to resolve it.

If I have something on the page like

<SCRIPT TYPE="text/javascript">
  alert('test');
  </SCRIPT>
 
 <cfajaximport tags="cfdiv">
<cfdiv bind="url:GetPorts.cfm"></cfdiv>

Everything works great, but if I take out the alert javascript from this page and put it into the application.cfm I get the error.
Does the GetPorts.cfm that is bound to the cfdiv tag use the dhtml menu javascript?
No the getports.cfm script just queries a database select count(*) as qryCount and then just does <cfoutput>#qrycount#</cfoutput>

the dhtml script wasnt the issue, the issue seemed to be putting any kind of javascript in the appliction.cfm file, have no idea why or how to resolve it but thats what causes the error to pop up.
It could be that the javascript files you are using have a javascript variable name that is conflicting with one of the coldfusion or something.

You shoudn't be putting any display code in your application.cfm file, that's a pretty standard best practice "no no". Try putting that code into a header file that you include with each request. you might also try putting your other javascript into a function and then using the AjaxOnLoad function to execute the dhtml menu stuf after the ajax stuff is done loading.

http://livedocs.adobe.com/coldfusion/8/htmldocs/functions_a-b_06.html#5178573
Well it isnt variables in the javascript because the below code doesnt work as well.

<SCRIPT TYPE="text/javascript">
  alert('test');
  </SCRIPT>

I have also tried in a heade rnot in application.cfm and that doesnt work either.  The code has to actually be in the processing page, not in any includes or in application.cfm

so what I ended up doing was just offloading all my javascript i put in the header and application.cfm and put it in the main page and it all works.

I did actually run accross a similar  issue the other day with some javascript that wasn't working correctly with the th cfgrid tag I was working on, then the strange thing is I moved the javascript in between the <head></head> tags and then it all started working fine. try putting all your javascript in the head and see if it helps.
hmm ya they are already between the <head> tags, tried moving gthem out though and same issue..wow frustrating  
ASKER CERTIFIED SOLUTION
Avatar of kc5sig
kc5sig

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
aha! that worked