Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/472.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在母版页标记上使用查询字符串_Javascript_Jquery_Asp.net_Vb.net - Fatal编程技术网

Javascript 在母版页标记上使用查询字符串

Javascript 在母版页标记上使用查询字符串,javascript,jquery,asp.net,vb.net,Javascript,Jquery,Asp.net,Vb.net,我需要提供一个查询字符串中的变量来告诉我在地图上绘制哪些图钉。目前,我必须硬编码啤酒名称,就像我在if语句中对“Stella”所做的那样。有没有一种方法可以让我引用我的查询字符串(beerName=Stella)来更改它。这是所有的母版页顺便说一句。任何帮助将不胜感激 $(document).ready(function () { $.ajax({ url: "Handler2.ashx", type: "post"

我需要提供一个查询字符串中的变量来告诉我在地图上绘制哪些图钉。目前,我必须硬编码啤酒名称,就像我在if语句中对“Stella”所做的那样。有没有一种方法可以让我引用我的查询字符串(beerName=Stella)来更改它。这是所有的母版页顺便说一句。任何帮助将不胜感激

$(document).ready(function () {


          $.ajax({
              url: "Handler2.ashx",
              type: "post",
              data: { "Action": "SearchByLocation" },
              success: function (data) {
                  for (var i = 0; data.Locations.length - 1; i++) {
                      var pushPin2 = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(data.Locations[i].Latitude, data.Locations[i].Longitude), null);
                      $("#newdiv li").append("<li><a href='" + "Main.aspx?beerName=" + data.Locations[i].beerName + "'>" + data.Locations[i].beerName + "</a></li>")
                      collectionInMemory = data;
                      if (data.Locations[i].beerName == "Stella") {
                          map.entities.push(pushPin2);

                      }

                  }


                 for (var j = 0; j < collectionInMemory.Locations.length - 1; j++) {
                     if(collectionInMemory.Locations[j].BeerName = "Stella") alert("datada");
                  }
              },
              error: function () {
                  alert("failure");
                  $("#result").html('There is error while submit');
              }

          });
$(文档).ready(函数(){
$.ajax({
url:“Handler2.ashx”,
类型:“post”,
数据:{“操作”:“SearchByLocation”},
成功:功能(数据){
对于(var i=0;data.Locations.length-1;i++){
var pushPin2=new Microsoft.Maps.Pushpin(新的Microsoft.Maps.Location(data.Locations[i].纬度,data.Locations[i].经度),null);
$(“#newdiv li”)。追加(“
  • ”) 收集内存=数据; if(data.Locations[i].beerName==“Stella”){ 地图.实体.推送(pushPin2); } } 对于(var j=0;j
    您可以像这样使用内联ASP.NET代码段,它将呈现查询字符串变量

      if (data.Locations[i].beerName == <%= Request.QueryString("beerName") %>) {
          map.entities.push(pushPin2);
          }
    
    if(data.Locations[i].beerName==){
    地图.实体.推送(pushPin2);
    }
    
    使用