Problem with APLJax
3 posts
• Page 1 of 1
Problem with APLJax
Brian,
I am having a problem running with the "production" version of MiServer 3.
(Since Eastbourne, I have been using BETA versions of MiServer 3.)
So, I have converted my ANTS code to us "Compose" rather than "Render", and that is working well up to the point when I expect the callback function "APLJax" to be triggered by a timer.
However, whenever the timer is triggered, instead of running "APLJax", the "Compose" function is being re-run.
I suspect the problem might be in the JScript I am using.
The APL that writes the JScript that has been working up to now includes the following "ajax" call
Have you any suggestions to what has been changed (since April 2016) that might be causing my problem?
I am having a problem running with the "production" version of MiServer 3.
(Since Eastbourne, I have been using BETA versions of MiServer 3.)
So, I have converted my ANTS code to us "Compose" rather than "Render", and that is working well up to the point when I expect the callback function "APLJax" to be triggered by a timer.
However, whenever the timer is triggered, instead of running "APLJax", the "Compose" function is being re-run.
I suspect the problem might be in the JScript I am using.
The APL that writes the JScript that has been working up to now includes the following "ajax" call
- Code: Select all
r,←⊂' $.ajax('
r,←⊂' {'
r,←⊂' url : "/hex.dyalog",'
r,←⊂' cache : false,'
r,←⊂' type : "POST",'
r,←⊂' dataType : "json",'
r,←⊂' complete : poll,'
r,←⊂' success : function(obj)'
r,←⊂' {'
r,←⊂' $.each(obj,function(i,d)'
r,←⊂' {'
r,←⊂' APLJaxReturn(obj);'
r,←⊂' });' ⍝ each
r,←⊂' }' ⍝ success
r,←⊂' });' ⍝ ajax
Have you any suggestions to what has been changed (since April 2016) that might be causing my problem?
Ray Cannon
Please excuse any smelling pisstakes.
Please excuse any smelling pisstakes.
-
ray - Posts: 238
- Joined: Wed Feb 24, 2010 12:24 am
- Location: Blackwater, Camberley. UK
Re: Problem with APLJax
Hi Ray!
Yeah, we needed to modify some of the APLJax processing. Previously we were treating any request that was an XMLHttpRequest as an APLJax call, but in an environment where there may be other XLMHttpRequests that were not intended to be APLJax calls, MiServer would inappropriately handle them. So, we needed to add a special header in the ajax() call to positively identify the request as an APLJax request. So you need to modify your code as follows (or use MiServer's _.Handler)...
However, in looking at that, I think I may want to update how we do this to use the JavaScript true constant, and not the string "true". If we do that, I'll let you know; it shouldn't impact many MiServer users as I suspect very few are writing their own ajax calls.
Also, another way to insert constant code (assuming your page is based on the MiPage class) is to use ScriptFollows which reads the block of subsequent contiguous comments as a character constant.
I hope this helps!
/Brian
Yeah, we needed to modify some of the APLJax processing. Previously we were treating any request that was an XMLHttpRequest as an APLJax call, but in an environment where there may be other XLMHttpRequests that were not intended to be APLJax calls, MiServer would inappropriately handle them. So, we needed to add a special header in the ajax() call to positively identify the request as an APLJax request. So you need to modify your code as follows (or use MiServer's _.Handler)...
r,←⊂' $.ajax('
r,←⊂' {'
r,←⊂' url : "/hex.dyalog",'
r,←⊂' cache : false,'
r,←⊂' type : "POST",'
r,←⊂' headers : {"isAPLJax" : "true"},'
r,←⊂' dataType : "json",'
r,←⊂' complete : poll,'
r,←⊂' success : function(obj)'
r,←⊂' {'
r,←⊂' $.each(obj,function(i,d)'
r,←⊂' {'
r,←⊂' APLJaxReturn(obj);'
r,←⊂' });' ⍝ each
r,←⊂' }' ⍝ success
r,←⊂' });' ⍝ ajax
However, in looking at that, I think I may want to update how we do this to use the JavaScript true constant, and not the string "true". If we do that, I'll let you know; it shouldn't impact many MiServer users as I suspect very few are writing their own ajax calls.
Also, another way to insert constant code (assuming your page is based on the MiPage class) is to use ScriptFollows which reads the block of subsequent contiguous comments as a character constant.
r,←ScriptFollows
⍝ $.ajax(
⍝ {
⍝ url : "/hex.dyalog",
⍝ cache : false,
⍝ type : "POST",
⍝ headers : {"isAPLJax" : "true"},
⍝ dataType : "json",
⍝ complete : poll,
⍝ success : function(obj)
⍝ {
⍝ $.each(obj,function(i,d)
⍝ {
⍝ APLJaxReturn(obj);
⍝ }); //each
⍝ } //success
⍝ }); //ajax
I hope this helps!
/Brian
-
Brian|Dyalog - Posts: 120
- Joined: Thu Nov 26, 2009 4:02 pm
- Location: West Henrietta, NY
Re: Problem with APLJax
Hi Brian,
Adding the extra line
in my JavaScript did the trick, and my Ants are once again marching across my MiServer page again!
After I originally wrote this code, I became aware if the ScriptFollows trick, but have not (as yet) bothered to re-write Ants using this feature. There are many such features that are now available under MiServer 3, that were not available/documented then.
Thanks again for the feedback, and for all the help you have given me in the past, not to mention all the hard work you have put into MiServer.
Thanks
Ray
Adding the extra line
- Code: Select all
headers : {"isAPLJax" : "true"},
in my JavaScript did the trick, and my Ants are once again marching across my MiServer page again!
After I originally wrote this code, I became aware if the ScriptFollows trick, but have not (as yet) bothered to re-write Ants using this feature. There are many such features that are now available under MiServer 3, that were not available/documented then.
Thanks again for the feedback, and for all the help you have given me in the past, not to mention all the hard work you have put into MiServer.
Thanks
Ray
Ray Cannon
Please excuse any smelling pisstakes.
Please excuse any smelling pisstakes.
-
ray - Posts: 238
- Joined: Wed Feb 24, 2010 12:24 am
- Location: Blackwater, Camberley. UK
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group