0

I want to pass a PHP array as URL parameter in GET method . Here is my php array : Array ( [0] => 4 [1] => 5 )

1st I convert it to angularJs array like this

$scope.myData.excludeList = '<?php echo JSON_encode($savedList);?>';

Then I pass this array like this :

$scope.myData = {};
$scope.myData.array =[];
var response = $http({
    url: 'http://localhost/control/file_list/', 
    method: "GET",
    params: $scope.myData.array 
});
response.success(function (data){
    $scope.list = data.list;
});

But when it hit the URL look like

http://localhost/control/file_list/%5%%22 lab lab lab.... how can I solve this ?

Drop Shadow
  • 845
  • 3
  • 12
  • 28

2 Answers2

1

Here is a good solution I think

var formData = {                        
                data1: val1,
                data1: val2
               };
Drop Shadow
  • 845
  • 3
  • 12
  • 28
0
var myJsonString = JSON.stringify(yourArray);

Convert array to JSON

then in php

json_decode($myJsonString, true);

Community
  • 1
  • 1
mokNathal
  • 533
  • 1
  • 6
  • 20