Michael Iglesias
Posts: 0
Joined: Tue Jul 23, 2013 8:51 pm

Following javascript is not executing.

The following javascript is not being executed when I successfully make my api call and assign the status of the api call to a variable.

var Keen=Keen{configure:function(e){this.cf=e},addEvent:function(e,t,n,i){this.eq=this.eq[],this.eq.push([e,t,n,i])},setGlobalProperties:function(e){this.gp=e},onChartsReady:function(e){this.ocrq=this.ocrq||[],this.ocrq.push(e)}};(function(){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src=("https:"==document.location.protocol?"[url=https://":"http://")+"dc8na2hxrj29i.cloudfront.net/code/keen-2.1.0-min.js&quotvar]https://":"http://")+"dc8na2hxrj29i.c...[/url] t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})();

Code: Select all

 // Configure the Keen object with your Project ID and (optional) access keys. 
 Keen.configure({ 
     projectId: localStorage.getItem("keen_project_id"), 
     writeKey: localStorage.getItem("keen_write_id") // required for sending events 
 }); 

// create an event as a JS object
var ticket = {
page: "create_maintenance_request",
tntID: localStorage.getItem('tntID')
};

// add event to "maintenance_tickets" collection
Keen.addEvent("maintenance_tickets", ticket);

Michael Iglesias
Posts: 0
Joined: Tue Jul 23, 2013 8:51 pm

Following javascript is not executing.

The javascript above runs perfectly when I place it inside an HTML panel to track page visits.

I am not trying to keep track of the amount of maintenance tickets submitted and wish to execute the following code upon completion of successful API call. I currently redirect users to the maintenance list page upon the completion of ticket submission. I pasted the code above the "Appery.navigateTo" but it is not being executed. The redirect is working as expected though.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Following javascript is not executing.

Being custom JavaScript with 3rd party JavaScript library, it's outside the scope of our support. I hope you understand. We don't mind giving you some guidance and hints.

Does this code work in a plain HTML page (outside of Appery.io)?
Did you try placing console.log(..) statements to see exactly where the script stops working.
You can also run the code in a debugger.

Michael Iglesias
Posts: 0
Joined: Tue Jul 23, 2013 8:51 pm

Following javascript is not executing.

Code does work on plain HTML page as well as within the app when placed inside a HTML Panel. It does not seem to work when placed inside a javascript function.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Following javascript is not executing.

Try running the code through a debugger or simply placing console.log(..) statements to see what's happening. You should also check if there are any errors in the console.

Return to “Issues”