数组显示未定义的jQuery发布功能

编程入门 行业动态 更新时间:2024-10-27 16:39:45
本文介绍了数组显示未定义的jQuery发布功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

你好朋友 我正在尝试使用$ .post()从数据库中获取数据,它会向我返回数据 我再次在拳头中使用$ .post() 我试图将数据推入第二个$ .post()中的数组中 数组长度显示在第二个$ .post()内部,但在它外部显示长度0 以下是我的代码

Hello Friends I am trying to get the data from database using $.post() it returns me data I am again using $.post() inside the fist one and i am trying to push that data in array inside second $.post() array length is showing inside second $.post() but outside it it is showing length 0 Below is my code

$.post('/Common/getInfo/', null, function (data) { var desc = []; var ultlng =[]; var count = 0; for (var i = 0; i < data.length; i++) { desc.push(data[i].Description); $.post('/Common/getLatlngInfo/', { id: data[i].ID }, function (data1) { for (var j = 0; j < data1.length; j++) { if (j == 0) { ultlng.push(new google.maps.LatLng(data1[j].Latitude, data1[j].Longitude)); } if (data1.length > 1) { if (j == data1.length - 1) { var flightPlanCoordinates = [ new google.maps.LatLng(data1[0].Latitude, data1[0].Longitude), new google.maps.LatLng(data1[1].Latitude, data1[1].Longitude), new google.maps.LatLng(data1[2].Latitude, data1[2].Longitude), new google.maps.LatLng(data1[3].Latitude, data1[3].Longitude), new google.maps.LatLng(data1[4].Latitude, data1[4].Longitude) ]; var flightPath = new google.maps.Polyline({ path: flightPlanCoordinates, geodesic: true, strokeColor: '#007ACC', strokeOpacity: 1.0, strokeWeight: 3 }); flightPath.setMap(map); } } else { ultlng.push(new google.maps.LatLng(data1[j].Latitude, data1[j].Longitude)); } } }); } for (var i = 0; i < desc.length; i++) { marker = new google.maps.Marker({ map: map, position: ultlng[i] }); (function (i, marker) { google.maps.event.addListener(marker, 'click', function () { if (!infowindow) { infowindow = new google.maps.InfoWindow(); } infowindow.setContent("<html><body><div style="min-height:50px; max-width: 200px;">" + data[i].Description + "</div></body></html>"); infowindow.open(map, marker); }); })(i, marker); } });

将ultlng []数组长度设为0,应为5 当5个5个元素被推入其中时 但是在$ post()之外显示的是长度 请给我解决方案, 在此先感谢

getting ultlng[] array length as 0 it should be 5 as 5 five elements are pushed into it but outside $post() it is showing o lenght Please get me solution for this, Thanks in advance

推荐答案

.post()它返回我数据 我再次在第一个拳头内使用 .post() it returns me data I am again using

.post() 我试图将数据推入第二个数组中的数据 .post() inside the fist one and i am trying to push that data in array inside second

.post() 数组长度显示在第二个 .post() array length is showing inside second

更多推荐

数组显示未定义的jQuery发布功能

本文发布于:2023-10-12 02:57:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483550.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数组   未定义   功能   jQuery

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!