Variabiles ajax Gönder

0 Cevap php

1.php

...
<script src="/jquery-1.3.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
var a=$a
var b=$b
var c=$c
apclick= function(){
$.ajax({

    url: 'a1.php',
    data: { a: a, b: b, c: c },
    datatype: json,
    success: function(results) {
          if (results.msg == 'success') {

      alert(a)
      alert(b)
      alert(c)
else {
alert(results.msg)
}
}
    },
    error: function(results) {
alert("Data returned: " + results.msg )
    }

})


             setTimeout("location.reload(true);",3000)           


            }
            return false

}
</script>

.....
<strong><br><a href="#" onclick="apclick();return false;">Afiseaza </a></strong>

a1.php

<?php
$return = array();
$a=$_POST['a'];
$b=$_POST['b'];
$c=$_POST['c']
if ($a=="hello"){
$return['msg'] = 'success';
$return['a'] = "Buna";
};
if ($b=="say"){
$return['msg'] = 'success';
$return['a'] = "Spune";
};
if ($c=="man"){
$return['msg'] = 'success';
$return['a'] = "Om";
};
header("Content-type: application/json");
echo json_encode($a);
echo json_encode($b);
echo json_encode($c);
?>

Questions is: How send a,b,c to a1.php and receive a,b,c in 1.php

0 Cevap