I want to send three arrays of data namely vertexa
, vertexb
and edge_id
to HTML page including JavaScript so as to run an algorithm Dijkstra on the vertices. Should I use JSON commands for this?
up vote
1
down vote
favorite
|
|
|||
|
up vote
4
down vote
|
You'll want to use json_encode on the data, like
$encoded is now
header has to happen before you output anything to the page, even a space or blank line, or PHP will give an error. After generating the data as a PHP array, to output it to JS on the initial page load, you can print it out as the following. Not you don't need to output a special header in this case; it's part of your normal text/html document. The header is for an Ajax return.
|
||||||||
|
up vote
1
down vote
|
Use On the servers side set content-types to |
||||||||||
|