Parsing javascript arrays in PHP

前端 未结 4 1978
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-05 05:47

I can\'t seem to figure out how to get a JS array into PHP.

What I have to work with looks like this:

var arrLow = [
{
\"e\": \"495864\",
\"rank\": \         


        
4条回答
  •  执笔经年
    2021-01-05 06:32

    //define javascript array 
    >var mainArray = {};    
    >       // inner loops
    mainArraySub['XXX'] = [];    
    
                 mainArray = JSON.stringify(mainArray);
          passing javascript array content in jquery ajax request as 
          $.ajax({
           type: "POST",
         data:{paramval:mainArray},
         dataType: "json",
        url: url,
       success: function(msg){
    
              }
          });    
    
    
    in POST request you will get as below
    
    {"row1":{"0":{"nnnn":"aaaa"},"1":{"Movie":"aaaa"},...}        
    
    // in a.php file call as below
    
    $Info = $_REQUEST['rowdata'];
    $tre = json_decode(stripslashes($Info),true);
    var_dump($tre);        
    

提交回复
热议问题