Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery change params or value in php for the XML page being queried
    primarykey
    data
    text
    <p>I am hoping that someone can help me.</p> <p>I am using PHP, AJAX, JQUERY and an XML file.</p> <p>I want to dynamically update the query string of the XML file using AJAX (not refreshing the page) and getting a new XML file and new results from the DB...</p> <p>I basically have all these things in place, but not sure how to update the parameters of the XML file.</p> <p>so basically I want to have a link or a button, or dropdown with the parameter values</p> <pre><code>&lt;button&gt;Test1&lt;/button&gt; &lt;button&gt;Test2&lt;/button&gt; &lt;button&gt;Test3&lt;/button&gt; </code></pre> <p>When I click the Button Test1 - it should set the XML file (within the JavaScript) to page.php?q=test1 if I click Test2 it should change the page.php to page.php?q=test2</p> <p>How do I set the XML file parameters to change based on the value of the button being submitted, If I can get the parameters to updated to the value of the button I am fine, and can do the refresh</p> <p>The XML page is indeed a PHP page, which generates the results in XML based on the query string passed to the page.</p> <p>If I manually change the querystring to page.php?q=test2 I do get the results based on the querystring, I just need this to happen on click</p> <p>Here is an example of the code I have (Updated the code to show exact example)</p> <pre><code> &lt;script&gt; var customIcons = { events: { icon: '/wp-content/uploads/gmaps/icons/car.png', }, bar: { icon: 'http://labs.google.com/ridefinder/images/mm_20_red.png', shadow: 'http://labs.google.com/ridefinder/images/mm_20_shadow.png' } }; google.maps.visualRefresh = true; var panorama; var entryPanoId = null; function initialize() { var xmap = new google.maps.LatLng(-26.245325,27.982386); var mapDiv = document.getElementById('map-canvas'); var map = new google.maps.Map(mapDiv, mapOptions); google.maps.event.addDomListener(mapDiv, 'click', showAlert); var mapOptions = { center: xmap, zoom: 10, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); var infoWindow = new google.maps.InfoWindow; downloadUrl("/wp-content/themes/geraldferreira/templates/phpsqlsearch_genxml.php", function(data) { var xml = data.responseXML; var markers = xml.documentElement.getElementsByTagName("marker"); for (var i = 0; i &lt; markers.length; i++) { var name = markers[i].getAttribute("name"); var address = markers[i].getAttribute("address"); var type = markers[i].getAttribute("type"); var map_icon = markers[i].getAttribute("map_icon"); var map_desc = markers[i].getAttribute("map_desc"); var map_info_url = markers[i].getAttribute("map_info_url"); var point = new google.maps.LatLng( parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))); var html = "&lt;h2&gt;" + name + "&lt;/h2&gt;"+map_desc + "&lt;br/&gt;&lt;b&gt;Address:&lt;/b&gt; "+ address+"&lt;br/&gt;More about&lt;br/&gt;&lt;button onclick='location.href=\""+map_info_url+"\"' class='btn btn-mini btn-info'&gt;"+ name +"&lt;/button&gt; &lt;button class='btn btn-mini btn-info' onclick='toggleStreetView(this);'&gt;Virtual Tour&lt;/button&gt;"; var icon = customIcons[type] || {}; var marker = new google.maps.Marker({ map: map, position: point, icon: icon.icon, shadow: icon.shadow }); bindInfoWindow(marker, map, infoWindow, html); } }); panorama = map.getStreetView(); var panoOptions = { position: xmap, visible: true, panoProvider: getCustomPanorama }; panorama.setOptions(panoOptions); var streetviewService = new google.maps.StreetViewService(); var radius = 100; streetviewService.getPanoramaByLocation(xmap, radius, function(result, status) { if (status == google.maps.StreetViewStatus.OK) { google.maps.event.addListener(panorama, 'links_changed', function() { createCustomLinks(result.location.pano); }); } });function bindInfoWindow(marker, map, infoWindow, html) { google.maps.event.addListener(marker, 'click', function() { infoWindow.setContent(html); infoWindow.open(map, marker); }); } function downloadUrl(url, callback) { var request = window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest; request.onreadystatechange = function() { if (request.readyState == 4) { request.onreadystatechange = doNothing; callback(request, request.status); } }; request.open('GET', url, true); request.send(null); } function doNothing() {} } function getCustomPanoramaTileUrl(pano, zoom, tileX, tileY) { return "/wp-content/uploads/virtual_tours/"+pano+'/images/'+tileX+'-'+tileY+'.png'; } function getCustomPanorama(pano) { switch(pano) { &lt;?php global $wpdb; $virtual_tours = $wpdb-&gt;get_results( "SELECT * FROM wp_virtual_tours" ); foreach($virtual_tours as $virtual_tour){ echo "case '".$virtual_tour-&gt;id."': return {location: {pano: '".$virtual_tour-&gt;id."', description: '".$virtual_tour-&gt;virtual_tour_name." - ".$virtual_tour-&gt;id."', latLng: new google.maps.LatLng(-26.245325,27.982386)},links: [], copyright: 'Imagery (c) 2010 Google', tiles: {tileSize: new google.maps.Size(512, 512),worldSize: new google.maps.Size(4096, 2048),centerHeading: ".$virtual_tour-&gt;virtual_tour_centerheading.",getTileUrl: getCustomPanoramaTileUrl}}; break;"; } ?&gt; default: return null; } } function createCustomLinks(entryPanoId) { var links = panorama.getLinks(); var panoId = panorama.getPano(); switch(panoId) { &lt;?php if ($_GET[virtualtour] != Null) { echo "case entryPanoId: links.push({heading: 310, description : 'Johannesburg Boat Show 2013', pano : '".$_GET["virtualtour"]."'}); break;"; } elseif ($_GET[virtualtour] == Null){ echo "case entryPanoId: links.push({heading: 310, description : 'Johannesburg Boat Show 2013', pano : '90'}); break;"; } ?&gt; &lt;?php global $wpdb; $virtual_tours = $wpdb-&gt;get_results( "SELECT * FROM wp_virtual_tours" ); foreach($virtual_tours as $virtual_tour){ echo ''.$virtual_tour-&gt;virtual_tour_links_code.''; } ?&gt; default: return; } } function toggleStreetView() { var toggle = panorama.getVisible(); if (toggle == false) { panorama.setVisible(true); } else { panorama.setVisible(false); } } function showAlert() { /*window.alert('DIV clicked');*/ } google.maps.event.addDomListener(window, 'load', initialize); &lt;/script&gt; </code></pre> <p>This is the XML(PHP FILE) where I need to add the parameter in the code above</p> <pre><code>downloadUrl("/wp-content/themes/geraldferreira/templates/phpsqlsearch_genxml.php" </code></pre> <p>So on click of button I want to pass the parameter to <code>phpsqlsearch_genxml.php?q=newvalue"</code> and refresh the page via Ajax instead of reloading the page</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload