jQuery .post / php problem

Hi all,

I’m having a problem using jQuery $.post with a php file. I have the following code:

[code=javascript]
$.post( “http://www.mywebsite.com/myfile.php”, {v1: v1_value, v2 : “string”, v3: v3_value});



I've checked in firebug that the "data values" are as expected going into the .post function. So I thought the problem might lie with the php code, which is as follows: 

[code=php]
<?php
// Sanity check
$cmd = "touch ajax_call.txt";
exec("$cmd 2>&1", $array); 

$v1  = $_POST['img'];
$v2 = $_POST['prog'];
$v3   = $_POST['value'];

// other code 
?>

The sanity check of file touching is happening. When I check the apache error_logs file, it says PHP Notice: Undefined index: v1 and there are similar errors for v2 and v3.

I don’t understand what I’m doing wrong? or is anything else I can try to debug this further?

Many thanks!

Your parameter names do not match.

$v1 = $_POST[‘v1’];
$v2 = $_POST[‘v2’];
$v3 = $_POST[‘v3’];

Hi speda1

Thanks for the reply, that was a mistake when i posting my original question, the code is in fact:

$v1 = $_POST[‘v1’];
$v2 = $_POST[‘v2’];
$v3 = $_POST[‘v3’];

So thats not the explanation. any other thoughts? Any way I could debug this?

just to add I’ve tried $_GET in the php file as well, which manually works with the url I’d expect, i.e.

test.php?v1=1&v2=2&v3=3

So should the php file be using $_POST or $_GET

Caught the problem - thanks for looking! seems like it was a typo