javascript - Angularjs send empty JSON to server (ONLY in IE 9 and greater) -


i have little issue angularjs script. i'm trying post data server (php script saves values database). works correctly in chrome, mozilla, opera , each other totally not in ie. tried ie9, 10 , 11 (all without add-ons)and still can't figure out. in ie angularjs posts empty json (something {}).

here's angularjs post script.

$scope.submitform = function() {              // posting data php file             $http({                 method  : 'post',                 url     : 'ajax/newinvoice.php',                 data    : $scope.invoice, //forms user object                 headers : {'content-type': 'application/x-www-form-urlencoded'}                              })                 .success(function(data) {                     getinvoices();                     $scope.invoice = {items: [{qty: 1,description: '',cost: 0,taxperc: 21}],odberatel: '',konecny_prijemce: '',datum_objednavky: new date(),datum_vystaveni: new date(),datum_splatnosti: new date(),datum_zdanitelneho_plneni: new date(),zpusob_uhrady: 'platba kartou',dodaci_metoda: 'osobní odběr'};                            });         }; 

and here's php.

<?php  require_once '../includes/db.php'; // mysql database connection script  $created = date("y-m-d h:i:s", strtotime("now"));  $query = "select id ang_faktury order id desc"; $result = $mysqli->query($query) or die($mysqli->error.__line__); $row = $result->fetch_assoc();  $last_invoice_id = intval($row["id"]); $year = date("y"); $month = date("m"); $idstring = str_pad(($last_invoice_id + 1), 5, '0', str_pad_left);//id faktury ang_faktury[id], ang_faktury_polozky[id_faktury] $facislo = 'ob/'.$year.'/'.$month.'/'.$idstring; //cislo faktury ang_faktury[cislo_faktury]  $_post = json_decode(file_get_contents('php://input'), true);  $dzp = $_post['datum_zdanitelneho_plneni']; $datum_zdanitelneho_plneni = substr($dzp, 0, 10);    $dzpform = date("d.m.y", strtotime($datum_zdanitelneho_plneni));  $do = $_post['datum_objednavky']; $datum_objednavky = substr($do, 0, 10);  $doform = date("d.m.y", strtotime($datum_objednavky));  $dv = $_post['datum_vystaveni']; $datum_vystaveni = substr($dv, 0, 10);   $dvform = date("d.m.y", strtotime($datum_vystaveni));  $ds = $_post['datum_splatnosti']; $datum_splatnosti = substr($ds, 0, 10); $dsform = date("d.m.y", strtotime($datum_splatnosti));  foreach($_post['items'] $item){           $sumpricetotal += $item['pricetotal'];     $query2="insert ang_faktury_polozky (id_faktury,name,cena,ks,dph_proc,dph,total) values('$idstring','$item[description]','$item[mjprice]','$item[qty]','$item[taxperc]','$item[taxsum]','$item[pricetotal]')";     $mysqli->query($query2); }  $spt = "{$sumpricetotal}"; $cbd = (($spt*100)/121); $dph = $spt - $cbd;  $query3="insert ang_faktury (id,created_at,cislo_faktury,datum_zdanitelneho_plneni,odberatel,konecny_prijemce,zpusob_uhrady,dodaci_metoda,cislo_objednavky,datum_objednavky,datum_vystaveni,datum_splatnosti,cena_bez_dph,dph,celkem_k_uhrade) values('$idstring','$created','$facislo','$dzpform','$_post[odberatel]','$_post[konecny_prijemce]','$_post[zpusob_uhrady]','$_post[dodaci_metoda]','$facislo','$doform','$dvform','$dsform','$cbd','$dph','$spt')"; $mysqli->query($query3);  mysqli_close($mysqli); ?> 

thanks advise.

check data before sending console.log(data), , check data after receiving print_r($_post) (in myfile.php)


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -