pkedpker Posted July 2, 2009 Share Posted July 2, 2009 I'm trying to do ajax to stop refreshing of page in my morpg the ajax code I use is just this and XMLHttp is a wrapper. <?php //just colors echo <<< o function updateBattle(objID){ var ajaxObj = new XMLHttp(); var url = 'index.php?p=battle'; var method = 'POST'; var params = '?fight={$_POST['name']}'; makeRequest(ajaxObj, method, url, params, objID); ajaxObj = null; } o; ?> inside wrapper <?php //its a commerical wrapper so i don't believe it has any problems. if (method == 'POST' && params != '') { XmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); XmlHttp.setRequestHeader("Content-length", params.length); XmlHttp.send(params); ?> problem is this is never triggered inside battle.php <?php } elseif(isset($_POST['fight'])) { //<---------- ?> I tried all of these things var params = '?fight={$_POST['name']}'; var params = 'fight={$_POST['name']}'; var params = '&fight={$_POST['name']}'; I know its my first time using ajax but i dont think thats the problem because it does download the page.. just hits my else statement instead of my elseif and no its nothing to do with my flow of if/elseif statements because else statement is at the very bottom. Link to comment https://forums.phpfreaks.com/topic/164459-solved-php-doesnt-realize-post-method/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.