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> Link to comment https://forums.phpfreaks.com/topic/235783-php-and-ajax-problem/ 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. Link to comment https://forums.phpfreaks.com/topic/235783-php-and-ajax-problem/#findComment-1211987 Share on other sites More sharing options...
Mod-Jay Posted May 8, 2011 Author Share Posted May 8, 2011 Please Delete this thread. Link to comment https://forums.phpfreaks.com/topic/235783-php-and-ajax-problem/#findComment-1212126 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.