I've looked at a lot of answers related to this question, as this question has been asked many times on stackoverflow. Most of the answers seem to involve sending the data through the ajaxvariable.send() portion of the ajax call. I'm thinking about using a different solution that I haven't seen posted (could be wrong, but I've looked at a lot of them). However, as it hasn't been posted or suggested somewhere else, I'm concerned I may be opening the door to security issues (or whatever else may be wrong with my method). Is there something wrong with sticking a JSON object inside of a URL variable, if the following hold true?
Assume the following:
(1) The amount of information being transferred in the object is not large.
(2) The variables put into the JSON object being passed are pulled from a database on the sending page and checked against the database on the receiving page (not checked directly in a query mind you, but rather against a range of possible values put inside of a PHP array) to confirm nothing has been altered before anything is done with the passed variable values.
Javascript, JSON (sending page):
...
var getplaninfo = {};
getplaninfo["initialfee"] = document.getElementById("initialfee").value;
getplaninfo["monthlyfee"] = document.getElementById("monthlyfee").value;
var planinfo = JSON.stringify(getplaninfo);
ajaxRequest.open("GET", "index.php?choice=" + planinfo, true);
ajaxRequest.send(null);
PHP (from within the include that is replacing the contents of a div on the sending page):
if (isset($_GET["choice"])) {
$returned = $_GET["choice"];
$decode = json_decode($returned,true);
$initialfee = $decode["initialfee"];
$monthlyfee = $decode["monthlyfee"];
}
The reason I ask is that I'm pretty new to AJAX. I'm pretty comfortable with security in PHP, but I'm not so much with AJAX yet. I appreciate your time.