Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $("#formZip").submit(function (event) {
- $("#result").text("");
- var zip = $(this).find("input[name='s']").val();
- var zipPersonArr = [];
- $(".zip-val-option").each(function (index) {
- zipPersonArr.push($(this).text());
- });
- var objectKeyVal = new Object();
- /* Loop each value from array */
- var count = $(".filters-group > div").length;
- var iCount = 1;
- var textInfo = "";
- console.log("aft" + iCount);
- zipPersonArr.forEach(function (element) {
- /* Ниже запрос */
- $.post(
- "https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=" + zip + "&destinations=" +
- element + "&key=AIzaSyAucEe5UVmL_dqOiCv4XaAxG94Ffr5L6sI", {
- func: "getNameAndTime"
- },
- function (data) {
- console.log(Object.values(data)[2]["0"].elements["0"].distance.value);
- var distaseVal = Object.values(data)[2]["0"].elements["0"].distance.value;
- console.log("Distanse:" + distaseVal + ", Zip:" + element);
- $("#result").append(distaseVal + ":" + element + "|");
- }, "json");
- if (iCount == count) {
- getFromResultDiv();
- }
- iCount++;
- }); /* End Loop each zip */
- console.log("Text info" + textInfo);
- return false;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement