Rayj Posted July 24, 2016 Share Posted July 24, 2016 I have a small PHP script that pulls some data out of a database. There are two parts to the data, a string variable and an integer. (ex: Chevy 22.55) I want to pass these to PIXI Javascript in order to display them like this: Chevy 22.55 Note: No space after Chevy. I don't know why posts are double spaced in this forum? Thanks, Ray Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 24, 2016 Share Posted July 24, 2016 Well, first step is to learn javascript for a day. Then you'll come to solution Unless you already did that and have a solution that somehow is not working, which we actually can help you with. Quote Link to comment Share on other sites More sharing options...
Rayj Posted July 24, 2016 Author Share Posted July 24, 2016 2 minutes ago, ivan.popelyshev said: Well, first step is to learn javascript for a day. Then you'll come to solution Unless you already did that and have a solution that somehow is not working, which we actually can help you with. Learning JS will not tell me how to pass data from PHP to Javascript. I've taken multiple Javascript tutorials. Not one mention of PHP. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 24, 2016 Share Posted July 24, 2016 Ah, so that's ajax problem. loader.add('mylevel', '/scripts/stuff.php'); loader.load(function(loader, resources) { parseLevel(resources.mylevel.data); //or .text, i really dont remember, please look in this object what it gives you; }); Loader is the same as for your resources: https://github.com/kittykatattack/learningPixi#displaying-sprites If you want to load new level after you already called "load", please just do loader.add('mylevel2', '/scripts/stuff.php?id=2', function(loader, resource) { parseLevel(resource.data); //or .text, i really dont remember, please look in this object what it gives you; }); and parseLevel is your function that makes level from that txt stuff Quote Link to comment Share on other sites More sharing options...
catafest Posted July 24, 2016 Share Posted July 24, 2016 Maybe is about php and java browser how is working. Youu have a start here: http://stackoverflow.com/questions/25093905/when-and-where-does-javascript-run-how-about-php-can-i-combine-the-two Also depends the structure of data over browser or server communication. This is my opinion. I'm not very good of that. Nice question. Quote Link to comment Share on other sites More sharing options...
Rayj Posted July 24, 2016 Author Share Posted July 24, 2016 I think using JSON.encode is doing the trick for me. Now have to figure out how to make my code reiterative. The integer will be changing fairly often. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 24, 2016 Share Posted July 24, 2016 1 hour ago, Rayj said: I think using JSON.encode is doing the trick for me. Now have to figure out how to make my code reiterative. The integer will be changing fairly often. OK, now we have an information we didnt have before: you need update it in realtime, and not just per stage or per level. Find a comet library for PHP and JS. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.