I've been looking around the forums without a solution to my problem. It's pretty simple, really, and I'd appreciate it if you could explain your answer if you would be so kind.

I'm new to AJAX and Javascript, and I need to send one variable from my javascript code and basically "convert" it into php. Here's what I have so far:

var selected = rowData.ID

jQuery.ajax({
    url: "test.php",
    type: 'POST',
    data: { selected },
    cache: false
});

I use this selected value further down in the code. I use PHP to display the (value of selected).

"vars": [ 
    "(value of selected)" 
],      

However, I can't seem to make my ajax request work and send the variable to my PHP file. Here's what my PHP file looks like:

$row = $_POST["selected"];

Thanks in advance for the help.

share|improve this question

1 Answer

try replacing your "data:" with this:

 data: { 'selected': selected },
share|improve this answer
Nope, not working :/ – minoue10 Jul 17 '12 at 4:23
works fine on my server. I can only suggest checking script error in other scripts on the same page and adding success call back to debug: success: function (data) { alert(data); } – vlscanner Jul 17 '12 at 15:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.