so I am trying to post and link to a dynamic URL and am using a jquery redirect to do so. I know this is probably not the best way, and I personally hate being redirected, but it works. Regardless, I am having trouble passing the dynamic url, which is generated based on database values for whichever marker is clicked on, into the jquery post form. Right now, it brings in the last value in the name and id of the last marker in my database, which makes sense to me, but is certainly not what I want to happen.
Here is my javascript code:
downloadUrl("phpsqlajax_genxml1.php", function (data) {
var xml = data.responseXML;
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var id = markers[i].getAttribute("id");
var name = markers[i].getAttribute("name");
var description1 = markers[i].getAttribute("description");
var type = markers[i].getAttribute("type");
var point = new google.maps.LatLng(
parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var url = "markerpages.php?name=" + name + "&id=" + id;
var html = "<b>" + name + "</b> <br/>" + description1;
var contentString = '<div id="content">' +
'<div id="siteNotice">' +
'</div>' +
'<h1 id="firstHeading" class="firstHeading">' + name + '</h1>' +
'<div id="bodyContent">' +
'<p>' + description1 + '</p>' +
'<p><a href="#" id="markerpages-link">link to dynamic PHP page</a>' +
'</p>' +
'</div>' +
'</div>';
Here is my jquery code:
$(document).on("click", "a", "markerpages-link", function () {
var form = $('<form action="' + url + '" method="post">' +
'<input type="hidden" name="api_url" value="' + url + '" />' +
'<input type="text" name="description2" value="' + description1 + '" />' +
'</form>');
$('body').append(form); // This line is not necessary, maybe for IE
$(form).submit();
});
Thank you for any and all help. It is greatly appreciated.