Get the radio button value through ajax to php file

前端 未结 5 869
失恋的感觉
失恋的感觉 2021-02-11 07:44

After clicking the radio button, the value from the radio button is not being passed when the onclick event is triggered. Here is my code:



        
5条回答
  •  无人共我
    2021-02-11 08:09

    Firstly make ajax to separate PHP page where you will access the radio value. Also make alert after you receive the data.

    $.ajax({
        url : "post.php",
        type : "POST",
        data: pass_data,
        success : function(data) {
            // alert radio value here
            alert(data);
        }
    });
    

    Crete a separate PHP file post.php where you access radio input. Since you are making POST request you need to use $_POST instead of $_GET to get radio button value.

    
    

提交回复
热议问题