Guest User

Untitled

a guest
Apr 16th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. $('#getLocationForm').submit(function(event) {
  2.  
  3. event.preventDefault();
  4. var location = $(this).serialize(); // this refers to submitted form, serizlize well see later in console:
  5. console.log(location);
  6.  
  7. var display = $("#resultscontainer");
  8.  
  9. $.ajax({
  10. type: "GET",
  11. url: "/~lebreuillyj/project/scripts/location.php?" + location,
  12. dataType: "json",
  13. success: function(result)
  14. {
  15. var data3 = JSON.stringify(result);
  16.  
  17. data3 = $.parseJSON(data3);
  18.  
  19. var locationoutput = "";
  20. locationoutput+= "<ul id='listingitem'>";
  21.  
  22. //MAIN ISSUE IN LOOP
  23. for(var i=0; i < result.length; i++)
  24. {
  25. locationoutput+= "<li class='listing' a href='#'>" + data3[i].display_name + " " + data3[i].lat + " " + data3[i].lon +"</a></li>";
  26. }
  27.  
  28. locationoutput+= "</ul>";
  29.  
  30. $("#locationresults_container").css("display", "block");
  31. $("#locationresults").css("display", "inline");
  32. $("#locationresults").html(locationoutput);
  33. },
  34. error: function(xmlHttpRequest, statusMessage, httpCode)
  35. {
  36. alert("HTTP code=" + httpCode + " statusMessage=" + statusMessage + " full response text" + xmlHttpRequest.responseText);
  37. alert("/~lebreuillyj/project/scripts/location.php?" + location);
  38.  
  39. $("#locationresults_container").html("<p class='hello'><h2>Please enter a search querie</h2></p>");
  40. }
  41. });
  42.  
  43. return false;
  44. });
  45.  
  46. <div id="location_container">
  47.  
  48. <h3>Current Location: </h3>
  49.  
  50. <div id="result">None</div>
  51.  
  52. <div id="location_button_container">
  53.  
  54. <button id="find_btn">Get Location</button>
  55.  
  56. <button id="change_btn">Change Location</button>
  57.  
  58. </div>
  59.  
  60. $(".listing").click(function(){
  61. console.log("hello");
  62. });
Add Comment
Please, Sign In to add comment