- Edited
hello I'm coding an online web text based rpg game, similar to the idea of www.kingsofchaos.com, no need for polling in these kinds of games.
my current plan is to have an index.html with a main javascript library, which has an ajax function and another function that dynamically loads an external javascript file
when a user clicks a link say battlefield it loads index.html#battlefield which then runs a function loadScript("battlefield") which then imports and runs battlefield.js
battlefield.js then calls using ajax game.pl?battlefield which outputs
1,432,player1,40000|2,535,player2,60500|etc... *** felt sending it this way would be better than in xml format coz it would save bandwidth :?
once fully received the battlefield.js will then parse the string and output it as proper html
say for example
<ul>
<li>1 432 player1 40000</li>
<li>2 535 player2 60500</li>
</ul>
and then insert it in to the innerHTML of a div called "main"
so its
index.html#xxx -> xxx.js -> game.pl?xxx
question: is there a better design than the one im implementing or is the design im coding ok?
my current plan is to have an index.html with a main javascript library, which has an ajax function and another function that dynamically loads an external javascript file
when a user clicks a link say battlefield it loads index.html#battlefield which then runs a function loadScript("battlefield") which then imports and runs battlefield.js
battlefield.js then calls using ajax game.pl?battlefield which outputs
1,432,player1,40000|2,535,player2,60500|etc... *** felt sending it this way would be better than in xml format coz it would save bandwidth :?
once fully received the battlefield.js will then parse the string and output it as proper html
say for example
<ul>
<li>1 432 player1 40000</li>
<li>2 535 player2 60500</li>
</ul>
and then insert it in to the innerHTML of a div called "main"
so its
index.html#xxx -> xxx.js -> game.pl?xxx
question: is there a better design than the one im implementing or is the design im coding ok?