I need to use the following coordinates in a separate php file and I guess the best way is to transfer via ajax.
The html is as follows:
<div id="canvas">
<div class="point1">
<div class="coord"></div>
</div>
<div class="point2">
<div class="coord"></div>
</div>
<div class="point3">
<div class="coord"></div>
</div> etc
</div>
The jQuery UI draggable function I’ve currently written currently shows the top and left position of each div directly underneath the div being dragged:
...
element = this;
var top = $(this).position().top;
var left = $(this).position().left;
$('.coord', this).text('Top: ' + top + 'px' + ' Left: ' + left + 'px');
...
But in order to now use each of the point coordinates in PHP variables do I need to split out $('.coordinates', this) etc into an array first to transfer via ajax into php – and if so does anyone know how?
Or is there a simpler way – as I’m sure there probably is?!? I’m just a bit confused!
Appreciate any advice or pointers.
Well, I’m not so advanced but if you wanna pass data from javascript(jquery) to PHP and as you say with ajax use the jquery method $.post:
And in the PHP file you catch those vars whith $_POST[“coordTop”] and $_POST[“coordLeft”]