0
function doit(user)
{
    jQuery.ajax({
        url:'http://www.xxxxxx.in/index.php',
        type:'POST',
        data:{id:user},
        success:function(data){
            if(data == "true")
            {
                //ileti("success","Done");
            }
        }
     });
 }

This is my index.php :

$user = $_REQUEST["id"];

Why is it that the value isn't passing?

Slater Victoroff
  • 21,376
  • 21
  • 85
  • 144
Johan
  • 85
  • 3
  • 8
  • What do you get when you `var_dump($_REQUEST)`? – jterry Jul 17 '13 at 17:10
  • What do you mean by,"not passing"? – Sinthia V Jul 17 '13 at 17:14
  • check on console or in firebug. What error do you get @Johan – Rakesh Shetty Jul 17 '13 at 17:16
  • *Questions asking for code must **demonstrate a minimal understanding** of the problem being solved. **Include attempted solutions**, **why they didn't work**, and the expected results.* Did you even take a look at what the AJAX call is returning to you? Did you take a look at the network response and also the console? What did they say? Did you get a network response code of 200? What was it? Your `datatype` should be set to `jsonp`. – Jeff Noel Jul 17 '13 at 17:29

3 Answers3

2

You need to echo it out to return it to the AJAX function, and you might as well use $_POST,

echo $_REQUEST["id"]; // or
echo $_POST["id"];
Zevi Sternlicht
  • 5,399
  • 19
  • 31
  • I dont want it to return it to ajax I want to post that value from ajax to php and save it in database. – Johan Jul 17 '13 at 18:34
1

As a security measure, AJAX does not allow you to make requests to other domains. If you still want to make a call on other server then do something like this.

The simplest way is first call a function on your own server and from that page use some other method like CURL to fetch data from other server. Ajax to Different Server Using PHP

Ravi Kant Mishra
  • 778
  • 1
  • 7
  • 13
0

Do some debugging. Try this :-

var_dump($_REQUEST);

and see what you get as output.

Vivek Sadh
  • 4,230
  • 3
  • 32
  • 49