CFajaxProxy callbackhandler doesn't work

robsan1
robsan1 used Ask the Experts™
on
I've developed an application that uses the CFajaxproxy tag to set up proxies to CFCs. Everything works as intended on my local machine, the proxy initiates the function, executes it and returns a value that is then handled by the setCallBackHandler function.

However, on the 'live' server, something doesn't work...

The function is executed through the proxy and it actually returns a value (I can see the value being returned in the CFDEBUG window)... but for some reason the callbackhandler doesn't execute at all and thus, the page isn't refreshed and no new data is being displayed.

I know that the proxy/cfc is working because the database is actually being updated as well as session variables and, as mentioned, the CFDEBUG window clearly shows a value is being returned.

The other strange thing is that the 'setErrorHandler' function works fine... i.o.w., when the CFC throws an error, it comes back with an error.

I have tested the  setCallbackHandler by adding a simple 'alert' method inside the function and it just doesn't execute.

There are no errors being reported in the FF error console but in the Chrome debugger, I do get the following error:

'throw new SyntaxError("parseJSON")' in the file 'CFIDE/scripts/ajax/package/cfajax.js'

I also get an 'uncaught exception' error in IE but the debugger shows me nothing.

The only other thing I could think of was the mappings to the root of the server are different than they are locally but if the errorHandler works, why wouldn't the setCallbackHandler work??

I am at a complete loss!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
can you post the code of your callback function?

do you have 'Prefix serialized JSON with' enabled in cf admin/Application.cfc on your live server?

Azadi

Author

Commented:
Hi Azadi,

I verified that 'Prefix Serialized JSON' was not checked on both the server and locally.

I've attached the entire JS file with all callback functions etc.

I have attached the display page for registration as well as the registration.cfc which is being called through the 'registerClass()' proxy.

// JavaScript Document
 
 
 
		var objConference = new conferenceClass();
		var objSchedule = new scheduleClass();
		var objRegister = new registerClass();
		var objAutoSchedule = new autoScheduleClass();
 
		
		
 
function getPath() {
var httpurl = ""
 
if (window.location.host == 'localhost') {
 
	httpurl = "http://localhost:8500/xxxx/"
	
	}
else if (window.location.host == 'xxx.xxx.xxx.xxx') {
	
	httpurl = "http://xxx.xxx.xxx.xxx/xxxx/"
	
	}
 
return httpurl;
 
}
 
function randomness() {
 randomID = Math.random() + (new Date().getTime());
 
 return randomID;
 
}
 
function autoScheduler(conference_id,type) {
 
if (type == 'cp') {
objAutoSchedule.autoSchedule(conference_id);
	}
else {
objAutoSchedule.bookPanel(conference_id);
}
}
 
function handleAutoScheduler(res) {
 
randomid = randomness();
path = getPath();
 
ColdFusion.navigate(path + "conferenceScheduler.cfm?conference_id=" + res.CONFERENCE_ID + "&uid=" + randomid,"conferenceMainScheduleBox");
 
if (res.NOPREFLIST != '') {
 
alert("Some Corporate Partners could not be scheduled because there is no more room!");
 
}
 
}
 
 
function showConferenceError() {
	
	alert("An Error Occured")
	
}
 
function handleConferenceResult(res) {
	//alert(res.REFERER);
	
		randomid = randomness();
		path = getPath();
		
		//alert(path + "conferenceSelectForm.cfm?conference_id=" + res.CONFERENCE_ID + "&uid=" + randomid);
		
		ColdFusion.navigate(path + "conferenceSelectForm.cfm?conference_id=" + res.CONFERENCE_ID + "&uid=" + randomid, "conferenceSelectBox");
		
		if (res.REFERER == 'addConference') {
		//alert("helloa");
		ColdFusion.navigate(path + "conferenceScheduler.cfm?conference_id=" + res.CONFERENCE_ID + "&uid=" + randomid, "conferenceMainScheduleBox");
		}
		
		else if (res.REFERER == 'room') {
			ColdFusion.navigate(path + "conferenceScheduler.cfm?conference_id=" + res.CONFERENCE_ID + "&uid=" + randomid,"conferenceMainScheduleBox");
		//alert("hello");
			//ColdFusion.navigate("conferenceScheduler.cfm?conference_id=" + res.CONFERENCE_ID, "conferenceMainScheduleBox");
		}
}
 
function handleScheduleResults(res) {
//res is a structure
var uid = Math.random();
//alert(res.session_slot_id)
//ColdFusion.window.hide('partnerSlotSelect');conferenceScheduleTab#conference_session_id#
//ColdFusion.Ajax.replaceHTML("conferenceScheduleTab" + res.conference_session_id,"dspSchedule.cfm?conference_id=" + res.conference_id + "&conference_session_id=" + res.conference_session_id,"POST",null,null,null);
path = getPath();
 
if(res.type == 'panelist') {
	
	ColdFusion.navigate(path + "dspPanelSlotSelect.cfm?conference_id=" + res.conference_id + "&conference_session_id=" + res.conference_session_id + "&room_id=" + res.room_id + "&session_slot_id=" + res.session_slot_id + "&uid=" + res.uid, res.uid);
 
	}
else {
ColdFusion.navigate(path + "dspSchedule.cfm?conference_id=" + res.conference_id + "&conference_session_id=" + res.conference_session_id + "&uid=" + uid, "slotArea" + res.session_slot_id + res.conference_session_id + res.room_id);
 
}
 
 
}
 
function addNewConference(conferenceid) {
	var conferenceStruct = new Object();
	
	
	
	conferenceStruct.conferenceid = document.getElementById('conference_idform').value;
	conferenceStruct.checkNewFacility = document.getElementById('newFacilityToggle').value;
	conferenceStruct.conference_name = document.getElementById('conference_name').value;
	conferenceStruct.date_of_conference = document.getElementById('date_of_conference').value;
	conferenceStruct.date_of_conference_end = document.getElementById('date_of_conference_end').value;
	
	if (conferenceStruct.checkNewFacility == 0) 
	
		{conferenceStruct.facility_id = document.getElementById('facility_id').value;
	}
	
	else 
		{
	conferenceStruct.facility_name = document.getElementById('facility_name').value;
	conferenceStruct.facility_address_1 = document.getElementById('facility_address_1').value;
	conferenceStruct.facility_address_2 = document.getElementById('facility_address_2').value;
	conferenceStruct.facility_city = document.getElementById('facility_city').value;
	conferenceStruct.facility_prov_state = document.getElementById('facility_prov_state').value;
	conferenceStruct.facility_postal_code = document.getElementById('facility_postal_code').value;
	conferenceStruct.facility_country = document.getElementById('facility_country').value;
	conferenceStruct.facility_contact = document.getElementById('facility_contact').value;
	conferenceStruct.facility_phone_no = document.getElementById('facility_phone_no').value;
	conferenceStruct.facility_fax_no  = document.getElementById('facility_fax_no').value;
	conferenceStruct.facility_web_address = document.getElementById('facility_web_address').value;
	
		}
//alert(conferenceStruct.date_of_conference,conferenceStruct.date_of_conference_end)
objConference.addConference(conferenceStruct);
 
}
 
function addConf() {
 
	//ColdFusion.Ajax.replaceHTML("conferenceSelectBox","newconference.cfm","POST",null,null,null);
	randomid = randomness();
	path = getPath();
	
	//alert(randomid + path + 'newconference.cfm?conference_id=&uid=' + randomid);
	
makewindow(randomid,path + 'newconference.cfm?conference_id=&uid=' + randomid,'Add New Conference','false','500','500');
 
}
 
function editwtf() {
 
conference_id = document.getElementById('conference_id').value;
 
randomid = randomness();
	path = getPath();
	
	makewindow(randomid,path + 'newconference.cfm?conference_id=' + conference_id + '&uid=' + randomid,'Edit Conference Details','false','500','500');
 
}
 
 
function addRoom(facility_id,conference_id) {
 
	roomName = document.getElementById('room_name').value;
	
	if (roomName == '') {
	
	alert('You must enter a room name')
	}
	else
	
	{
	objConference.addRoom(facility_id,conference_id,roomName);
	}
 
}
 
function removeRoom(room_id, conference_id) {
 
objConference.removeRoom(room_id,conference_id);
 
}
 
 
 
 
 
function manageSchedule() {
 
conference_id = document.getElementById('conference_id').value;
path = getPath();
location = (path + "conferencemgr.cfm?conference_id=" + conference_id);
 
}
 
 
 
// this function let's a user select a corporate partner for a slot
function partnerSlotSelect(conference_id,conference_session_id,room_id,session_slot_id,uuid) {
	
	randomid = randomness();
	path = getPath();
	
	makewindow(randomid, path + 'dspPartnerSlotSelect.cfm?conference_id=' + conference_id + '&conference_session_id=' + conference_session_id + '&room_id=' + room_id +'&session_slot_id=' + session_slot_id + '&uid=' + randomid,'Add a Corporate Partner','true','500','200');
 
}
 
// this function let's a user select panelists for a slot
function panelSlotSelect(conference_id,conference_session_id,room_id,session_slot_id,uuid) {
	
	randomid = randomness();
	path = getPath();
	
	makewindow(randomid,path + 'dspPanelSlotSelect.cfm?conference_id=' + conference_id + '&conference_session_id=' + conference_session_id + '&room_id=' + room_id +'&session_slot_id=' + session_slot_id + '&uid=' + randomid,'Add a Panel','false','750','500');
 
}
 
function clearSlot(conference_id,conference_session_id,room_id,session_slot_id) {
 
var SlotStruct = new Object();
 
SlotStruct.session_slot_id = session_slot_id
SlotStruct.conference_session_id = conference_session_id;
SlotStruct.room_id = room_id;
SlotStruct.conference_id = conference_id;
 
objSchedule.clearSlot(SlotStruct);
 
}
 
function removeSlotPart(conference_id,conference_session_id,room_id,session_slot_id,customerno,uid,type) {
 
 
var partnerSlotStruct = new Object();
 
partnerSlotStruct.session_slot_id = session_slot_id
partnerSlotStruct.conference_session_id = conference_session_id;
partnerSlotStruct.room_id = room_id;
partnerSlotStruct.customerno = customerno;
partnerSlotStruct.conference_id = conference_id;
partnerSlotStruct.uid = uid;
partnerSlotStruct.type = type;
 
objSchedule.deletePartnerFromSlot(partnerSlotStruct);
 
}
 
 
//#conference_id#,#room_id#,#session_slot_id#,#conference_session_id#
function selectPartnerForSlot(conference_id,room_id,session_slot_id,conference_session_id,uid,type) {
 
var partnerSlotStruct = new Object();
//#session_slot_id##conference_session_id##roomquery.room_id#
 
partnerSlotStruct.session_slot_id = session_slot_id
partnerSlotStruct.conference_session_id = conference_session_id;
partnerSlotStruct.room_id = room_id;
partnerSlotStruct.partner_id = document.getElementById(type + '_id' + session_slot_id + conference_session_id + room_id + uid).value;
partnerSlotStruct.conference_id = conference_id;
partnerSlotStruct.type = type;
partnerSlotStruct.uid = uid;
 
objSchedule.addPartnerToSlot(partnerSlotStruct);
 
}
 
 
function makeChair(conference_slot_schedule_id,conference_id,conference_session_id,room_id,session_slot_id,customerno,uid,type) {
 
var makeChairSlotStruct = new Object();
 
makeChairSlotStruct.conference_slot_schedule_id = conference_slot_schedule_id;
makeChairSlotStruct.conference_id = conference_id;
makeChairSlotStruct.conference_session_id = conference_session_id;
makeChairSlotStruct.room_id = room_id;
makeChairSlotStruct.session_slot_id = session_slot_id;
makeChairSlotStruct.customerno = customerno;
makeChairSlotStruct.uid = uid;
makeChairSlotStruct.type = type;
 
 
 
objSchedule.makeChairForSlot(makeChairSlotStruct);
 
 
}
 
 
function registration(stepNo,otherValue) {
//alert("somnething");
var registerStruct = new Object();
 
if (stepNo == 1) {
	registerStruct.stepNo = stepNo;
	registerStruct.session_slot_id = document.getElementById('session_slot_id').value;
	
}
 
else if (stepNo == 2) {
	registerStruct.stepNo = stepNo;
}
 
else if (stepNo == 5) {
 
registerStruct.notes = document.getElementById('registration_notes').value;
 
}
 
else if (stepNo == 6) {
 
 
registerStruct.stepNo = stepNo;
 
}
 
 
objRegister.registerStruct(registerStruct);
 
}
 
function registrationGoBack() {
 
objRegister.goBack();
 
}
 
function slotPrefs(fieldid,session_slot_id){
 
//alert(fieldid);
 
conference_session_id = document.getElementById(fieldid).value;
 
objRegister.slotPrefs(conference_session_id,session_slot_id);
 
}
 
function chairPrefs(fieldid,session_slot_id,type) {
 
	chair_id = document.getElementById(fieldid).value;
 
	objRegister.chairPrefs(chair_id,session_slot_id,type);
}
 
 
function resetPrefs(prefList,sessionDisplay,tableName) {
 
objRegister.resetSlotPrefs(prefList,sessionDisplay,tableName);
 
 
}
 
function handleRegisterResults (res) {
//alert("I hate javascript");
 
randomid = randomness();
path = getPath();
 
 
ColdFusion.navigate(path + 'registrationSteps.cfm?step=' + res + '&uid=' + randomid,'registrationLayout');
 
}
 
 
 
//function viewUnbooked(conference_id) {
//
//randomid = randomness();
//	
//	makewindow(randomid,'dspPanelSlotSelect.cfm?conference_id=' + conference_id + '&conference_session_id=' + conference_session_id + '&room_id=' + room_id +'&session_slot_id=' + session_slot_id + '&uid=' + randomid,'Add a Panel','false','750','500');
//
//
//}
 
 
function showElement(elementid) {
 
	document.getElementById(elementid).style.display='block';
 
}
 
function hideElement(elementid) {
 
	document.getElementById(elementid).style.display='none';
 
}
 
		objConference.setErrorHandler(showConferenceError);
		objConference.setCallbackHandler(handleConferenceResult);
		objSchedule.setErrorHandler(showConferenceError);
		objSchedule.setCallbackHandler(handleScheduleResults);
		objRegister.setErrorHandler(showConferenceError);
		objRegister.setCallbackHandler(handleRegisterResults);
		objAutoSchedule.setErrorHandler(showConferenceError);
		objAutoSchedule.setCallbackHandler(handleAutoScheduler);

Open in new window

registrationCFC.txt
registrationsteps.txt
registration.txt

Author

Commented:
I've uploaded it to a different server now and it works there as well as it works locally. It appears that the only place it doesn't work is on the server where it is supposed to work.

For working copy:
Please look at: http://76.12.219.84/erdi/conferencemgr.cfm?action=registration&conference_id=23&user=2

Unfortunately I can't give access to the client server as it is not mine and don't know if that is ok...
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Author

Commented:
I just read your post again and it mentions that 'Prefix serialized JSON with' could be set in the Application.cfc?? That could be the issue. I don't have access to that file as the site that I am adding this application to is running on a proprietary CMS called rave7.

Let me see if the guy who built it knows about this.

Author

Commented:
OK, I checked with the developer and he doesn't even know what this means, so I am sure he didn't explicitly set it in the Application.cfc

In the mean time I will just have to rewrite some of the code.
ok, let's check a few more things:

1) what do you have in the onRequestStart() method in Application.cfc? please post the contents of onRequestStart() if you can (delete any sensitive info from there like dsn names, passwords, etc).

if your onRequestStart() method includes any files (like headers/stylesheets/javascript) these files will be added to ajax responses as well, thus breaking them due to malformed json.

2) do you perchance have a stray onRequestStart.cfm file in there somewhere? that will have the same effect as above.

3) do you have onRequest() method in your Application.cfc? that could break ajax calls as well.

4) same as above goes for onRequestEnd() method - do you include any files/content in it?

Azadi

Commented:
Sorry, I went on vacation...

I solved the problem. The main problem was that I couldn't access the Application.cfm file inside the root folder. I extended the Application.cfm file by adding an Application.cfc file to the web site root folder and named it the same as the Application name in the application.cfm file.

Everything was fixed after that...

Thanks for your help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial