Shadowing Posted April 17, 2012 Share Posted April 17, 2012 Hey guys im having trouble making a header go off on a php script using ajax wondering if anyone knows what I need to do to make this happend. I put to gether a real simple example $(function(){ $("select#name_list").change(function(){ $.ajax({ url: "/System_Lords/functions/function_common_buttons.php?functions=change_planet_ajax", type: 'POST', dataType: 'json', data: { name_list: $('#name_list').val() } }); }); }); The function on the php script function change_planet_ajax() { header("Location: /system_lords/dominion.php");exit(); } Quote Link to comment https://forums.phpfreaks.com/topic/261087-making-a-header-fire-using-ajax/ Share on other sites More sharing options...
requinix Posted April 17, 2012 Share Posted April 17, 2012 What's the point of the redirection? Quote Link to comment https://forums.phpfreaks.com/topic/261087-making-a-header-fire-using-ajax/#findComment-1338073 Share on other sites More sharing options...
Shadowing Posted April 17, 2012 Author Share Posted April 17, 2012 oh there is more code that goes with it. I just took it out. changes a session then refreshes page. also validates something from data base i have planets in a drop down box, as you change planets, it sets a default planet by updating a session I can redirect using java script but IE8 has a bug with window.open it seems. another idea i came up with is not using ajax at all. and just make a button hidden and fire the button. This code is for making a buttonless drop down box Quote Link to comment https://forums.phpfreaks.com/topic/261087-making-a-header-fire-using-ajax/#findComment-1338084 Share on other sites More sharing options...
requinix Posted April 17, 2012 Share Posted April 17, 2012 Okay... Still not sure what that redirect is supposed to do... Are you trying to use it to redirect the original page? Can't do it that way. You'd have to send data that says "you need to redirect and here is where you need to go". Like maybe echo json_encode(array("action" => "redirect", "location" => "/system_lords/dominion.php")); success: function(data) { if (data && data.action == "redirect") { document.location = data.location; } else { // ??? } } Quote Link to comment https://forums.phpfreaks.com/topic/261087-making-a-header-fire-using-ajax/#findComment-1338135 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.