php - Sending value, get nothing -
i created ajax function sends data php file wrong because when die it, holds nothing, , know ajax function written good. here how sending it:
xmlhttp.send(dop);
and here how recieve in php file:
$selectedlang = isset($_post['dop']) ? $_post['dop'] : '';
what doing wrong? i'am recieving info badly. coz can see parameteres in ajax function. please help, need fast.
<script type="text/javascript"> function run() { var dop = document.getelementbyid("kalba").value; return dop; } function insertdata() { var dop = run(); if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else {// code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.open("post","style/wps-light/datafile.php",true); xmlhttp.setrequestheader("content-type","application/x-www-form-urlencoded"); xmlhttp.send("reiksme=" + encodeuricomponent(dop)); } </script>
datafile.php:
<?php $selectedlang = isset($_post['dop']) ? $_post['dop'] : ''; die("viskas ok $selectedlang"); ?>
you need that:
$selectedlang = isset($_post['reiksme']) ? $_post['reiksme'] : '';
because reiksme
key in $_post
array, not dop
:
xmlhttp.send("reiksme=" + encodeuricomponent(dop)); ^^^^^^^
Comments
Post a Comment