GARAIS Posted August 8, 2014 Report Share Posted August 8, 2014 Sveiki es gribēju pajautāt vai ir iespējams sataisīt funkciju jQuery kas lasa config.php faila uzstādījumus? Quote Link to comment Share on other sites More sharing options...
codez Posted August 8, 2014 Report Share Posted August 8, 2014 (edited) Uztaisi php failu, kuru pieprasi kā javascriptu un kurā json formā izvadi savu configu. <?php header("Content-type: application/x-javascript"); ?> var Config = <?php echo json_encode($config); ?>; Pievieno šo failu ar <script> tagu pirms pārējiem failiem. Un tālāk Config.mansparametrs. Edited August 8, 2014 by codez Quote Link to comment Share on other sites More sharing options...
jurchiks Posted August 9, 2014 Report Share Posted August 9, 2014 (edited) Izklausās jau feini, tikai... Config.db.user, Config.db.password Edited August 9, 2014 by jurchiks Quote Link to comment Share on other sites More sharing options...
codez Posted August 9, 2014 Report Share Posted August 9, 2014 Tad jātaisa vai nu kāds filtrs, kurš ņem sarakstu ar publiskajiem laukiem un eksportē tos, vai arī hardkodē: <?php header("Content-type: application/x-javascript"); ?> var Config = {}; Config.public = <?php echo json_encode($config->public); ?>; Config.someOther = <?php echo json_encode($config->someOther); ?>; Config.apiKeys = <?php echo json_encode($config->apiKeys); ?>; 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.