Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/420.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/3/html/84.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 jquery第二次发布文本框为空_Javascript_Html_Ajax_Jquery - Fatal编程技术网

Javascript jquery第二次发布文本框为空

Javascript jquery第二次发布文本框为空,javascript,html,ajax,jquery,Javascript,Html,Ajax,Jquery,我使用此单击事件函数发布数据。第一次它完全正常工作,第二次我检查调试模式gcX和gcY文本框值为空,但gcZone值正常。为什么 $(document).on('click', "#InsertGc", function () { var id = $(this).attr('id'); var url = '@Url.Action("SetGeographicCordinateList")'; var X = ($.tr

我使用此单击事件函数发布数据。第一次它完全正常工作,第二次我检查调试模式gcX和gcY文本框值为空,但gcZone值正常。为什么

 $(document).on('click', "#InsertGc", function () {
            var id = $(this).attr('id');
            var url = '@Url.Action("SetGeographicCordinateList")';
            var X = ($.trim($('#gcX').val()));
            var Y = ($.trim($('#gcY').val()));
            var Zone = $('#gcZone option:selected').val();
            $.post(url, { X: X, Y: Y, zone: Zone, ActionType: true }, function (data) {
                if (data == "True") {
                    var p = "<tr class='tRow'> <td  id='gcX' class='tbody'>" + X + "</td><td id='gcY' class='tbody'>" + Y + "</td><td id='gcZone' class='tbody'>" + Zone + "</td>";
                    p += "<td class='tbody'><a href='#' title='حذف ' class='DelIcon' ></a></td></tr>";
                    $('#trGC:first').before(p);
                }
            });
        });
$(document).on('click',“#InsertGc”,函数(){
var id=$(this.attr('id');
var url='@url.Action(“setgeographycordinatelist”);
var X=($.trim($('#gcX').val());
变量Y=($.trim($('#gcY').val());
var Zone=$('#gcZone选项:选中').val();
$.post(url,{X:X,Y:Y,zone:zone,ActionType:true},函数(数据){
如果(数据==“真”){
var p=“”+X+“”+Y+“”+Zone+“”;
p+=”;
$('trGC:first')。在(p)之前;
}
});
});

第一次插入

<td  id='gcX' class='tbody'>" + X + "</td><td id='gcY' class='tbody'>" + Y + "</td>
“+X+”“+Y+”

现在,您有两个id为
gcX
gcY
的元素,它们不是空的。

在第一篇文章之后,您是否创建了gcX和gcY的多个实例?您可以在执行命令之前执行此操作。这是否覆盖了以前的gcX和gcY?如果不是,则在该点上有具有相同ID的重复元素。没错。我理解这个问题