Mod-Jay Posted May 7, 2011 Share Posted May 7, 2011 Im trying to make an AJAX button to load a php code. I dont know whats wrong with it atm. Could you take a look at the code and try to help? Ajax: function MakeRequest() { var xmlHttp = getXMLHttp(); xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState == 4) { HandleResponse(xmlHttp.responseText); } } document.savecode.submit(); xmlHttp.open("GET", "edit.php?save=true", true); xmlHttp.send(null); } function getXMLHttp() { var xmlHttp try { //Firefox, Opera 8.0+, Safari xmlHttp = new XMLHttpRequest(); } catch(e) { //Internet Explorer try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert("Your browser does not support AJAX!") return false; } } } function HandleResponse(response) { document.getElementById('SavedFile').innerHTML = response; } PHP: <?php echo "<input type='submit' onClick=\"document.savecode.submit();\" name='submit' value='Save code' />"; echo "<form name='savecode' action='edit.php?save=true' method='POST' ><textarea id=\"code\" name='code' rows=\"*\" cols=\"*\">" .htmlspecialchars($contents) . "</textarea>"; echo "<input type='hidden' value='$page' name='page' id='page'/>"; echo "</form>"; ?> <div id="SavedFile"> </div> Quote Link to comment Share on other sites More sharing options...
Mod-Jay Posted May 7, 2011 Author Share Posted May 7, 2011 How would i do that in POST. ? That = load the button. Quote Link to comment Share on other sites More sharing options...
Mod-Jay Posted May 8, 2011 Author Share Posted May 8, 2011 Please Delete this thread. 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.