ok guys question has been asked many times have looked through of answers , attempted have said no avail. according posts have read , know should working , have no idea why not. have script running javascript parsing out names array. trying send array, through ajax, php server can variables in php. have looked @ google debugger , posts fine when try access variable via $_post['name'] nothing shows up. when if check if name set using isset nothing happens well. im @ loss here. here's code. displays beginning , end not middle. have spent long on , not understand why not working. in advance.
<script> $(function(){ $("#teamsubmit").click(function() { //code here //loop through colmns in team div var teamarray = []; $("#teams .team .column").each(function(index, element){ //loop through items in column var $this = $(this); //console.log($(this)); //console.log("hello"); thisteam = ''; $this.children(".portlet").each(function(index1, element){ //thisteam += ($(this).find(".portlet-header").text(); //console.log("inside .portlet"); //console.log('length =' + ($(this).length - 1) + ' index =' + index1); if(($this.children(".portlet").length - 1) === index1){ thisteam += ($(this).find(".portlet-header")).text(); //console.log("new team"); } else{ thisteam += ($(this).find(".portlet-header")).text() + ","; } }); console.log(thisteam); teamarray[index] = thisteam; }); //console.log(thisteam); //console.log(teamarray); jsonarray = json.stringify(teamarray); $("#teams").html(""); console.log(jsonarray); $.ajax({ type: "post", url: 'settings.php', data: {json : jsonarray}, //data: jsonarray, datatype: 'json', success: function(data) { //alert("success!"); console.log(jsonarray); } }); //grab javascript array , query , update db <?php //echo "console.log('begin '" . isset($_post['json']) .");"; //$test = $_post['jsonarray']; //echo $test; if(isset($_post['json'])){ //$array = $_post['json']; $teammembers = json_decode($_post['json']); //echo "<script> console.log($teammembers); </script>"; echo "console.log('middle');"; //echo "$teammembers"; //get highest t_id , increment 1 //loop through insert sea_teams //loop through insert sea_team_user } echo "console.log('end');"; ?> });
});
Comments
Post a Comment