0

Below is my array contents in javascript. I'm passing it using get call to a php page. I am also passing other array's along with this array. Those array values are passed completely. Only this array is passing partial values. I also alerted it in javascript and its complete there. Whereas in php its taking only 2 values instead of 14.

var testPlanNameArray= ["Eligibility-Real Time Eligibility Cascading Validation", "Eligibility-SubmitterRouting", "Eligibility alias for defth", "Eligibility-Submitter x", "Eligibility-SubmitterRouting", "Eligibility-SubmitterRouting & Partner alias", "Eligibility-SubmitterRouting", "Eligibility-SubmitterRouting & Partne", "Eligibility-SubmitterRouting & Partner", "Eligibility-SubmitterRouting ", "Custom Maps Validation", "Custom Maps Validation", "Eligibility-Real Time Eligibility Custom Maps Validation", "Eligibility-Real Time Eligibility Custom Maps Validation"];

I'm passing using below code to php

$.get("dbValidation.php?&testIDArray=" + testIDArray + "&testPlanNameArray=" + testPlanNameArray + "&errorArray=" + errorArray + "&historyErrorDescArray=" + historyErrorDescArray  + "&expectedDEPProp=" + expectedDEPProp  + "&actualDEPProp=" + actualDEPProp).done(function(data3) {
                                // alert(testPlanNameArray);
                                        console.log(data3);
                                        console.log(testPlanNameArray);
                            });

In php page Iam just doing

<?php
$testPlanNameArray = explode(",", $_GET['testPlanNameArray']);
print_r($testPlanNameArray);
?>

When I do console.log(data3) it will print

Array
(
    [0] => Eligibility-Real Time Eligibility Cascading Validation
    [1] => Eligibility-SubmitterRouting 
)

I tried $testPlanNameArray = json_decode($_GET['testPlanNameArray']); but still it is not taking complete value. The problem is only with respect to this array. For rest array it is working fine.

4
  • What does var_dump($_GET) show? Commented Dec 9, 2018 at 4:47
  • It is printing ["Eligibility-Real Time Eligibility Cascading Validation", "Eligibility-SubmitterRouting", "Eligibility alias for defth", "Eligibility-Submitter x", "Eligibility-SubmitterRouting", "Eligibility-SubmitterRouting & Partner alias", "Eligibility-SubmitterRouting", "Eligibility-SubmitterRouting & Partne", "Eligibility-SubmitterRouting & Partner", "Eligibility-SubmitterRouting ", "Custom Maps Validation", "Custom Maps Validation", "Eligibility-Real Time Eligibility Custom Maps Validation", "Eligibility-Real Time Eligibility Custom Maps Validation"] in console. Commented Dec 9, 2018 at 4:52
  • That doesn't make sense. It should print an associative array with all the parameter names as keys. Commented Dec 9, 2018 at 4:52
  • Like "testPlanNameArray" => Array(15) ( ... ) Commented Dec 9, 2018 at 4:53

1 Answer 1

1

There may be an encoding issue. I suggest you pass an object to $.get, and it will encode it properly.

$.get("dbValidation.php", {
    testIDArray: testIDArray,
    testPlanNameArray: testPlanNameArray,
    errorArray: errorArray,
    historyErrorDescArray: historyErrorDescArray,
    expectedDEPProp: expectedDEPProp,
    actualDEPProp: actualDEPProp
}).done(...)

This encoding will actually create arrays in the $_GET parameters, so you don't need to use explode() or json_decode() at all.

Note that there's generally a limit to the length of URL parameters, typically 1024 or 2048. So trying to pass long arrays on the URL may not work well. You should use $.post, which has much higher limits.

Sign up to request clarification or add additional context in comments.

10 Comments

Thanks for replying @Barmar . I will try now and let you know in short time.
I tried above answer and in php I did $testIDArray = $_GET['testIDArray']; $testPlanNameArray = $_GET['testPlanNameArray']; // $testPlanNameArray = json_decode($_GET['testPlanNameArray']); // $testPlanNameArray = array(explode(",", $_GET['testPlanNameArray'])); $errorArray = $_GET['errorArray']; $historyErrorDescArray = $_GET['historyErrorDescArray']; // $errorArraySecond = explode(",", $_GET['errorArraySecond']); $expectedDEPProp = $_GET['expectedDEPProp']; $actualDEPProp = $_GET['actualDEPProp'];
I'm getting 414 status in browser console
That's the error for a URL too long. You're running into the limit I mentioned.
You need to switch to POST.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.