U
U
Uzair Izha2015-10-21 23:52:31
JavaScript
Uzair Izha, 2015-10-21 23:52:31

How to transfer a variable from jquery to php?

$('input[name="radioName"]:checked').val();
For example, how to assign this value to the php / variable

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilyusha Prokopiev, 2015-10-22
@iliapro

It must be sent using the POST or GET method. I would choose POST, the code would look like this:

$("#radio").click(function(){
    $.post("doc.php", {cokie:$("#radio").val()});
});

That is, it takes the input value with id=radio and sends it via POST to the doc.php document. PHP code should be like this:
<?php
    $radio = htmlspecialchars(strip_tags($_POST['radio']));
?>

I immediately wrote a small check so that it was not too easy to get into your server)

H
Hazrat Hajikerimov, 2015-10-22
@hazratgs

Send Ajax request

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question