473,326 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How to handle data produced by a PHP script on a web page?

Let's start with saying I'm a PHP . My goal is to process some data created by a PHP script, using JS.

Imagine my PHP script produces an array [1, 3, 7, 5]. I would like to use this array for making a chart. But somehow I don't understand how to make this data accessible for a JS script. Should I store it in a variable? If yes, how can I access it? Thanks a lot.
Dec 11 '19 #1
1 1463
gits
5,390 Expert Mod 4TB
depends how you implement your code. PHP can be called via an (XML)HttpRequest for example and return the data in JSON-format (typical way these days) or you can write plain text like:

Expand|Select|Wrap|Line Numbers
  1. var arr = ['your array elements'];
into a script-node of the html-page. JavaScript is executed in the browser - so the browser would take care of the parsing at the time the page is loaded and you would have an accessible variable for JavaScript (call this the 'legacy' way of doing such - but it can have some advantages in some cases to go this route).

Note: for PHP the JavaScript-code is just plain text - while as soon this text hits the browser - it becomes executable
Dec 11 '19 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: vishal | last post by:
when a user clicks on a hyperlink i want to pass data to linked page. but what i want is that this data should not be visible to user. i mean is there any way that i can pass data except get method...
6
by: Perdit | last post by:
My 1st page calls a 2nd that uses same data from a database. What is the best way to get the data in the second: a new call to the database or passing array through session variable?? I seems...
1
by: Robin | last post by:
now i have a text area, when user enter their ID (10 chars), a script will use the id to use this ID to get the user data, and fill the form automatically. how can i use javascript to get data...
2
by: Stefan Mueller | last post by:
I've a HTML page where you can add a lot of data to a dynamic table created with JavaScripts. At the moment this data is stored in a two dimensional array (JavaScript). But how can I transfer this...
2
by: Joe | last post by:
Hi, I have an asp.net script that connects to MS Access database and displays data in a table. For some reason I am do not know how to display data say in ascending order of column1. I have...
4
by: Andrea De Santi | last post by:
How can I redirect to another page with form data? In asp Classic I write: <form ... action="filename">...</form> and in then target page I write <%=request.form("fieldname")%> ..... but in...
4
by: Vasantha peddireddy | last post by:
I am posting a page to another page (form post). The data grid on the second page is being populated with data. Now, on page load of the second page, I would like to send the grid data on this page...
0
by: Glen | last post by:
Is there any way to post data to an ASP.Net form and then display the page to the user with the posted data from a client app? Here's what I'm trying to do: Serialize a business object (order)...
4
by: moondaddy | last post by:
I have a htm page where I need to pass some data to an aspx page as a means of sending data to the database. I don't need to see the aspx page so I was going to put it in a hidden iframe. This...
6
by: =?Utf-8?B?Rmx5Z3V5?= | last post by:
I am trying to keep from reloading my XmlDocument every time my page reloads. To do this I am using ViewState. System.Xml.XmlDocument myDataXmlDoc = new System.Xml.XmlDocument();...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.