0

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']; ?>
6
  • see your console for any error.. Commented Jul 18, 2013 at 13:07
  • What result are you getting and what result do you expect? Commented Jul 18, 2013 at 13:09
  • 1
    Where do you see null? you haven't got the chance to see any result Commented Jul 18, 2013 at 13:09
  • Which "php POST var" ? You are using GET here Commented Jul 18, 2013 at 13:11
  • I´m sorry, i mean the "php GET var". The console have no error and the result should be "Value is: juhu" Commented Jul 18, 2013 at 13:17

1 Answer 1

2

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");
   }
});
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, now i get the php output in a alert box on my android phone, but this output should be on the webpage;)
Well, that is not your question, your question was why your not getting the result, and that's solved. try here chat.stackoverflow.com/rooms/29074/html-css-dom-webdesign , you need to gain 20 rep, though

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.