user2289728
user2289728

Reputation: 31

Ajax GET but php variable is null

i try to send via ajax a simple string, but the php GET var is null. Thank you

function postJSON(){
$.ajax({
type: "GET",
url: "http://www.my-server.de/file.php",
data: { 'dataString': "juhu" },
cache: false,
success: function()
    {
        alert("Order Submitted");
    },
    error: function()
    {
        alert("Error");
    }
});

php:

 <?php 
 echo "Value is:";
 echo $_GET['dataString']; ?>

Upvotes: 0

Views: 154

Answers (1)

iConnor
iConnor

Reputation: 20189

Maybe You should try this

$.ajax({
   type: "GET",
   url: "http://www.my-server.de/file.php",
   data: { 'dataString': "juhu" },
   cache: false,
   success: function( response ){
       alert( response );
   },
   error: function() {
       alert("Error");
   }
});

Upvotes: 2

Related Questions