Assign jquery value to php variable

后端 未结 3 1513
轻奢々
轻奢々 2020-12-21 04:05

In same page i set the jquery value while click the button. i want pass the value to php variable in same page without form submitting.



        
3条回答
  •  执笔经年
    2020-12-21 04:57

    If at all you want to send php value to php page using jquery and ajax, then first of all, create input text with type hidden. put your php value in it. and when you click then get that value from that input type hidden in jquery and then pass it to whichever page you want.

    Do some thing like this.

    $(".next").click(function (){
    
    var php_val=$("#php_val").val();//it is getting value from hidden filed whose id is 'php_val'.
    
    //make ajax call with this as follows
    
    $.post("a.php",{php_val:php_val},function(data){
    
    //a.php is page name where u want to send php value.
    })
    
    
    });
    
    
    

    I hope this answers your questions

提交回复
热议问题