How to pass value from javascript to php file

后端 未结 2 1328
我在风中等你
我在风中等你 2021-01-28 14:47

I am getting value via JQuery as something like this

var query= popURL.split(\'?\');  
var dim= query[1].split(\'&\'); 
var popWidth = dim[0].sp         


        
2条回答
  •  执念已碎
    2021-01-28 14:59

    Take a look at the jQuery api documentation, in particular to the jQuery.ajax() function. You'll find documentation and many useful examples. This is a piece of code from that page that does exactly what you've requested:

    $.ajax({
       type: "POST",
       url: "some.php",
       data: "name=John&location=Boston",
       success: function(msg){
         alert( "Data Saved: " + msg );
       }
     });
    

    (Of course you can also pass the data by simply using GET params and appending them to the url)

提交回复
热议问题