Firstly, I need to premise this with the fact that this is the first time i’m needing to do anything with JSON files so my lingo is probably wrong.
I am trying to integrate a 3rd party JS library (FullCalendar Scheduler) and it needs vales as a JSON url.
I have a simple server connect query that returns the necessary result but i can’t figure out how to get this into a usable JSON file/url to use with FullCalendar Scheduler.
From reading this form, my understanding is that all the server connect actions output as a JSON in order to send the data back to the server, and looking at the output of my query does in fact look ALMOST like a usable JSON URL. This is what the output in the browser returns:
Appreciate that. I have managed to find the files, and maybe its just my lack of understanding or perhaps the issue is something o do with FullCalendar or how I’ve put the URL in.
From what can see though, because the JSON file has the query name at the start of it, in the below case {“select”: then FullCalendar doesn’t seem to work.
You need to parse the result and access the value of the pair.
So if result contains {“select”:[{“id”:1,“title”:“John Jones”},{“id”:2,“title”:“Peter Green”},{“id”:3,“title”:“Alan Jones”},{“id”:4,“title”:“Mike Tyson”},{“id”:6,“title”:“Alice Struve”}]}
Thanks @JonL.
That is exactly what I need to happen…Ive come to that conclusion myself during the day as I plodded through this…
Now. How do I achieve that?
Is that editing the PHP file? Or is that JavaScript language I need to put in the FullCalendar script to parse the PHP query so that only the JSON array is returned?
In the file where you are invoking the scheduler and where you have the results of the SC available to you.
You need to adapt it and change the result variable with the actual Wappler variable that contains the results of your SC.
There is probably an App Connect method that will provide you directly with the value, but it will be based on what i said above. However, I don’t know it as I haven’t been in the need of it.
@Teodor, @George Is there a way in Wappler (SC or AC) to achieve what Jon has suggested?
I'm looking around now, but really just trial and error seeing if i can get it to work. Essentially returning a JSON file that has just the array of data from a SC query, WITHOUT the query name and {} at the begining of the file.
Thanks again @s.alpaslan and @tesla for the suggestions. Unfortunately i have not been able to get this to work. I also went back to some of the old FullCalendar posts BEFORE it was implemented and found similar suggestions on using dmx.parse.
This is what i have got in the JS file (i’ve also tried as a script in the HTML head):
I’ve tried a number of other combinations, and have also tried this on a vary plain HTML page with no other app connect components loaded except the bare minimum to get the FC Calendar to display.
Does anyone have any other insights as to why this isn’t working?
I have not been able to figure out how to write the JS code that @JonL suggested yet…
The only time I used dmx.parse i put the values into a variable, then used that variable in my JS function.
Eg var eventValues = dmx.parse(‘SC_events.data.query1’)
JonL suggested using .select after the parse of the json values so this is what I would try…
A quick follow up.
Here is Patrick talking about dmx.parse...
In that thread he mentioned that you have to wait for the server connect to load it’s data first before you can parse it in JS. The way he mentioned (that I followed) was to invoke the JS function with an ondone=“myfunction()” in the server connect action.
Thanks @tesla but unfortunately i still can’t get the damn thing to load… Bangin my head against a wall here the last couple of days lol.
I’ve tried the onload command and it works in that I can see that it loads a var from a script (a simple alert with some text) but its still not working in loading the events or resources for Full Calendar.
I think the issue lies deeper.
If i simply try to set a variable in app connect to display the results of the query (before using dmx.parse, so i can see what is happening)
So if i use dmx.parse on that same variable in a JS script, using a simple ‘Alert’ function to see the results, that what i see. And if that is what FullCalendar is seeing as the events then no wonder its not working.
If i drill further down the query and select the two fields (id and title) this is what it looks like: