Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/21.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 无法解决';未定义索引';ajaxpost错误_Javascript_Php_Jquery_Ajax_Google Maps - Fatal编程技术网

Javascript 无法解决';未定义索引';ajaxpost错误

Javascript 无法解决';未定义索引';ajaxpost错误,javascript,php,jquery,ajax,google-maps,Javascript,Php,Jquery,Ajax,Google Maps,我知道这个问题已经被问过很多次了,但我几乎把所有提出的解决方案都看了一遍,似乎都不管用。首先,这是我的文件结构: index.php -js map.js -css main.css 以下是我想做的: 我使用谷歌地图API,我在地图上的不同位置放置了许多标记。当用户单击其中一个标记时,我希望将一个特定变量提交到index.php,以便在SQL查询中使用它。这是我的代码: map.js index.php 我在我的中引用了这些jQuery库: <script src="http

我知道这个问题已经被问过很多次了,但我几乎把所有提出的解决方案都看了一遍,似乎都不管用。首先,这是我的文件结构:

index.php
-js
  map.js
-css
  main.css
以下是我想做的: 我使用谷歌地图API,我在地图上的不同位置放置了许多标记。当用户单击其中一个标记时,我希望将一个特定变量提交到index.php,以便在SQL查询中使用它。这是我的代码:

map.js index.php

我在我的中引用了这些jQuery库:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css" />


我尝试了所有可能的语法更改,但它已经困扰了我好几天了。

索引文件位于较高的目录中,您必须进行更改

url: '/index.php',


你看过浏览器控制台中的请求/响应了吗?更简单的
google.maps.event.addListener(marker,'click',function(){var place=1234;$.post('/index.php',{place':place},function(data){alert(data)})})
@JayBlanchard-It-post;然后GET@mplungjan尝试了这个方法,但没有成功,直到没有希望,它返回了一个成功,所以我假设它成功地发布到url,但是它没有在php代码中设置变量“place”。try而不返回google.maps.event.addListener(marker,'click',(function(marker,I){//return function(){var place 1234;$.ajax({type:'POST',url:'/index.php',data:'place=“+place,success:function(data,status){alert(status)}}};//}}(marker,i));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css" />
url: '/index.php',
url: '../index.php',