javascript - Get php variable from server to client -
I am in the process of writing an app with phonegap and one aspect is to include my app to read The ability to create variables from a PHP file on my server, which are created by reading PHP from a SQLite3 database, I have received PPH and SQLT3 to work together. However, how can I use JQuery / Ajax / Javascript to display the value of serverside PHP variables on the ClientIndexXM file?
I have tried some code:
Clientside HTML
& lt; Html & gt; & Lt; Top & gt; & Lt; Script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Script & gt; $ .ajax ({url: "http://5.175.191.73/test.php", datatype: "Jason", // Return type data is jsonn success: function (data) {// <--- (Data) Jason Format is in Warning (DataTest 1); // Parse Jason Data}}); & Lt; / Script & gt; & Lt; / Html & gt;
Server SidePyP
& lt; Php $ test = array (); $ Test ['test1'] = '1'; $ Test ['test2'] = '2'; $ Test ['test3'] = '3'; Echo json_encode ($ test); ? & Gt;
Any help would be appreciated!
var phpArray = JSON.parse (data); Then use phpArray.test1
to get value for test 1 in your php array.
Comments
Post a Comment