Note that there are some explanatory texts on larger screens.

plurals
  1. POajax in form, then jquery to display filled form fields
    primarykey
    data
    text
    <p>I have a form that requires a physical address. Once the user enters the full address, I have a button that says "Verify address". I want to be able to click that button, trigger an ajax call that will call a file in the server which will get the longitude and latitude of that address, then return to the form with those coordinates, and display a div with them. Dont worry about figuring out the coordinates. Im just trying to figure out the whole ajax call and jquery display upon response from the server. Thanks</p> <p>So, I did this to have things working: </p> <pre><code>$(document).ready(function() { //if verify button is clicked $('#verify').click(function () { var address = $('input[name=address]'); var city = $('input[name=city]'); var state = $('input[name=state]'); var zip = $('input[name=zip]'); var country = $('select[name=country]'); //organize the data for the call var data = 'address=' + address.val() + '&amp;city=' + city.val() + '&amp;state=' + state.val() + '&amp;zip=' + zip.val() + '&amp;country=' + country.val(); //start the ajax $.ajax({ url: "process.php", type: "GET", data: data, cache: false, success: function (html) { //alert (html); if (html!='error') { //show the pin long and lat form $('.form2').fadeIn('slow'); } else alert('Error: Your location cannot be found'); } }); //cancel the submit button default behaviours return false; }); }); </code></pre> <p>process.php returns the longitude and latitude back in a variable as: "longitude,latitude". How do I access that data back in the front end so I can populate the form fields with it? Thanks a lot for the great responses.</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.
 

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