PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WEBDEV 2024 → Push Server Data to Browser Procedure
Push Server Data to Browser Procedure
Started by Mister RUAN, Aug., 31 2017 9:08 PM - 4 replies
Registered member
208 messages
Popularité : +1 (1 vote)
Posted on August, 31 2017 - 9:08 PM
Good day

I have a PHP site and I use JAVA graphs. The graph work as long as the data come from a browser code for that is the only way to add data to a JAVA script in Webdev. If I populate an array of data from my Code from MySQL data I cannot push it to the Browser Procedure array. Is there any other way?

Regards

Ruan
Posted on August, 31 2017 - 10:51 PM
Hi Ruan,

Well, if you are using a JS graph, you HAVE to talk to it in JS...

However, nothing prevents you from preparing the data in server code,
then send it to the browser side several ways.

By example, you can call the server side with ajaxexecute, and get the
result as a string. You then use the content of the string to call you
JS graph.

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM
(open source)

More information on http://www.fabriceharari.com


Le 8/31/2017 à 1:08 PM, Mister RUAN a écrit :
Good day

I have a PHP site and I use JAVA graphs. The graph work as long as the
data come from a browser code for that is the only way to add data to a
JAVA script in Webdev. If I populate an array of data from my Code from
MySQL data I cannot push it to the Browser Procedure array. Is there any
other way?

Regards

Ruan
Registered member
208 messages
Popularité : +1 (1 vote)
Posted on September, 01 2017 - 11:03 AM
Fabrice Harari wrote:
Hi Ruan,

Well, if you are using a JS graph, you HAVE to talk to it in JS...

However, nothing prevents you from preparing the data in server code,
then send it to the browser side several ways.

By example, you can call the server side with ajaxexecute, and get the
result as a string. You then use the content of the string to call you
JS graph.

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM
(open source)

More information on http://www.fabriceharari.com


Le 8/31/2017 à 1:08 PM, Mister RUAN a écrit :
Good day

I have a PHP site and I use JAVA graphs. The graph work as long as the
data come from a browser code for that is the only way to add data to a
JAVA script in Webdev. If I populate an array of data from my Code from
MySQL data I cannot push it to the Browser Procedure array. Is there any
other way?

Regards

Ruan


Hi Fabrice

Thanks for our assistance but I cannot get the ajaxexecute to work in the JS Browser code.

Is there any examples anywhere where I can see how this is done in Webdev 22?

Regards

Ruan
Registered member
208 messages
Popularité : +1 (1 vote)
Posted on September, 05 2017 - 2:01 PM
Fabrice Harari wrote:
Hi Ruan,

Well, if you are using a JS graph, you HAVE to talk to it in JS...

However, nothing prevents you from preparing the data in server code,
then send it to the browser side several ways.

By example, you can call the server side with ajaxexecute, and get the
result as a string. You then use the content of the string to call you
JS graph.

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM
(open source)

More information on http://www.fabriceharari.com


Le 8/31/2017 à 1:08 PM, Mister RUAN a écrit :
Good day

I have a PHP site and I use JAVA graphs. The graph work as long as the
data come from a browser code for that is the only way to add data to a
JAVA script in Webdev. If I populate an array of data from my Code from
MySQL data I cannot push it to the Browser Procedure array. Is there any
other way?

Regards

Ruan



Hi Fabrice

I have tested the ajaxexecute function and worked to return a string from the server code. I am working with a graph and I am trying to return an array of int. The server side creates the array 100% but it seems that it doesn't pull through to Browser code or JS.

This is Server Code with Ajax ON:
Procedure MyGraphGata()

arrLines is array of int
arrLines = [1,2,3,4,5,6]


RESULT arrLines


This is Browser Code:
Procedure Var()
//
IsArray is array of int

IsArray = AJAXExecute(MyGraphGata)

RESULT IsArray


This is the JAVA Script:
function LoadChart(loader) {
var ctx = document.getElementById("myChart").getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: '# of Votes',
data: loader,
backgroundColor: [
'rgba(255, 99, 132, 0.2)',
'rgba(54, 162, 235, 0.2)',
'rgba(255, 206, 86, 0.2)',
'rgba(75, 192, 192, 0.2)',
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: [
'rgba(255,99,132,1)',
'rgba(54, 162, 235, 1)',
'rgba(255, 206, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 159, 64, 1)'
],
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
}
}
});}


And This is the Call from button click with JS switched on and not WL:
LoadChart(Var());


Am I missing something? Why does is not return the Arra?

Thanks

Ruan
Posted on September, 05 2017 - 3:31 PM
Hi

as indicated in the help, the ajaxecute functions returns a STRING.
Therefore you need to transform the array into a string BEFORE sending
it back to the browser, and you need to manage the content of the string
on the browser side.

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM
(open source)

More information on http://www.fabriceharari.com


Le 9/5/2017 à 6:01 AM, Mister RUAN a écrit :
Fabrice Harari wrote:
Hi Ruan,

Well, if you are using a JS graph, you HAVE to talk to it in JS...

However, nothing prevents you from preparing the data in server code,
then send it to the browser side several ways.

By example, you can call the server side with ajaxexecute, and get the
result as a string. You then use the content of the string to call you
JS graph.

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM
(open source)

More information on http://www.fabriceharari.com


Le 8/31/2017 à 1:08 PM, Mister RUAN a écrit :
Good day

I have a PHP site and I use JAVA graphs. The graph work as long as the
data come from a browser code for that is the only way to add data to a
JAVA script in Webdev. If I populate an array of data from my Code from
MySQL data I cannot push it to the Browser Procedure array. Is there any
other way?

Regards

Ruan


Hi Fabrice

I have tested the ajaxexecute function and worked to return a string
from the server code. I am working with a graph and I am trying to
return an array of int. The server side creates the array 100% but it
seems that it doesn't pull through to Browser code or JS.

This is Server Code with Ajax ON:
PROCEDURE MyGraphGata()
arrLines is array of int
arrLines = [1,2,3,4,5,6]


RESULT arrLines


This is Browser Code:
PROCEDURE Var()
//
IsArray is array of int

IsArray = AJAXExecute(MyGraphGata)

RESULT IsArray


This is the JAVA Script:
function LoadChart(loader) {
var ctx = document.getElementById("myChart").getContext('2d');
    var myChart = new Chart(ctx, {
        type: 'bar',
        data: {
            labels: ["Red", "Blue", "Yellow", "Green", "Purple",
"Orange"],
            datasets: [{
                label: '# of Votes',
                data: loader,
                backgroundColor: [
                'rgba(255, 99, 132, 0.2)',
                'rgba(54, 162, 235, 0.2)',
                'rgba(255, 206, 86, 0.2)',
                'rgba(75, 192, 192, 0.2)',
                'rgba(153, 102, 255, 0.2)',
                'rgba(255, 159, 64, 0.2)'
                ],
                borderColor: [
                'rgba(255,99,132,1)',
                'rgba(54, 162, 235, 1)',
                'rgba(255, 206, 86, 1)',
                'rgba(75, 192, 192, 1)',
                'rgba(153, 102, 255, 1)',
                'rgba(255, 159, 64, 1)'
                ],
                borderWidth: 1
            }]
        },
        options: {
            scales: {
                yAxes: [{
                    ticks: {
                        beginAtZero:true
                    }
                }]
            }
        }
    });}


And This is the Call from button click with JS switched on and not WL:
LoadChart(Var());


Am I missing something? Why does is not return the Arra?

Thanks

Ruan