S
SteveYoungTbird
I am using the following function to call a PHP script which then
returns its result to the callback javascript function "loadJSON". This,
which is really the HTML GET Method, works fine except when the points
variable is large and then obviously it doesn't work.
function getElevationIntermediate(points) {
var script = document.createElement('script');
document.body.appendChild(script);
script.src = 'http://' + geoSpokeAddressTest + '?spoke=' + points +
'&callback=loadJSON';
}
Therefore I would like to use the HTML POST method instead but I cannot
find out how to do this from within JavaScript. I have tried many ideas
including the following but the PHP script receives the variables but
doesn't use the callback.
HTML
<form id="postit" style="display:none" method="post" action="">
<input id="spoke">
<input id="callback">
<input type="submit">
</form>
JavaScript
var phpScript = "http://mysite/postex.php",
callback = "loadJSON";
document.getElementById('postit').action = phpScript;
document.getElementById('spoke').value = points;
document.getElementById('callback').value = callback;
document.getElementById('postit').submit();
PHP
$latlngs = $_POST["spoke"];
$callback = $_POST["callback"];
............................
$json1 = json_encode($heights);
echo "$callback($json1)";
Thanks in advance for any advice or pointers , Steve.
returns its result to the callback javascript function "loadJSON". This,
which is really the HTML GET Method, works fine except when the points
variable is large and then obviously it doesn't work.
function getElevationIntermediate(points) {
var script = document.createElement('script');
document.body.appendChild(script);
script.src = 'http://' + geoSpokeAddressTest + '?spoke=' + points +
'&callback=loadJSON';
}
Therefore I would like to use the HTML POST method instead but I cannot
find out how to do this from within JavaScript. I have tried many ideas
including the following but the PHP script receives the variables but
doesn't use the callback.
HTML
<form id="postit" style="display:none" method="post" action="">
<input id="spoke">
<input id="callback">
<input type="submit">
</form>
JavaScript
var phpScript = "http://mysite/postex.php",
callback = "loadJSON";
document.getElementById('postit').action = phpScript;
document.getElementById('spoke').value = points;
document.getElementById('callback').value = callback;
document.getElementById('postit').submit();
PHP
$latlngs = $_POST["spoke"];
$callback = $_POST["callback"];
............................
$json1 = json_encode($heights);
echo "$callback($json1)";
Thanks in advance for any advice or pointers , Steve.