I’m developing a game, part of which is user being able to put on and take off cloths. The part of the image changing works perfectly, but the second function I added – to automatically change the „submit button” value from „Put on” to „take off” doesn’t work.
Here is complete JavaScript code:
Expand|Select|Wrap|Line Numbers
- function player_image(action,objekt) {
- var http = false;
- if(navigator.appName == "Microsoft Internet Explorer") {
- http = new ActiveXObject("Microsoft.XMLHTTP");
- } else {
- http = new XMLHttpRequest();
- }
- http.abort();
- http.open("GET", "ajax_server/game_server.php?page=" + action + "&objekt=" + objekt, true);
- http.onreadystatechange=function() {
- if(http.readyState == 4) {
- document.getElementById('player_image').innerHTML = http.responseText;
- }
- }
- http.send(null);
- }
- function get_ajax_content(page,action,div) {
- var obj = false;
- if(navigator.appName == "Microsoft Internet Explorer") {
- obj = new ActiveXObject("Microsoft.XMLHTTP");
- } else {
- obj = new XMLHttpRequest();
- }
- obj.abort();
- obj.open("GET", "ajax_server/game_server.php?page=" + page + "&action=" + action, true);
- obj.onreadystatechange=function() {
- if(http.readyState == 4) {
- document.getElementById(div).innerHTML = obj.responseText;
- }
- }
- obj.send(null);
- }
And the HTML/PHP code for the div:
<a href="#" class="popout"><img src="images/things/'.$item['pilt'].'" border="0"><span>Amount: '.$items[$a][1].'<br /><div id="clothing_options">'.$clothing_options.'</div></span></a>
And the Javascript error message I get is: Line 30 Char: 5 Error: http is undefined…however there is NO http at line 30.
I have been struggling with that for long time and looks like I wount be finding a solution on my own, thereby I’ll ask here for help.
Thanks in advance