Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.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
Php 将ajax jquery请求显示响应发送到对话框jqueryui_Php_Jquery_Ajax_Jquery Ui - Fatal编程技术网

Php 将ajax jquery请求显示响应发送到对话框jqueryui

Php 将ajax jquery请求显示响应发送到对话框jqueryui,php,jquery,ajax,jquery-ui,Php,Jquery,Ajax,Jquery Ui,我有这样的链接 我需要在带有城市id或名称的对话框中显示城市的详细信息,但无法发送数据 <a class="dot" style="top:110px; left:145px;" continent="NA" id="1" name="1"></a> 我需要在单击时显示弹出对话框 但单击后对话框不会打开 <script language="javascript" type="text/javascript"> $('a.dot').cli

我有这样的链接 我需要在带有城市id或名称的对话框中显示城市的详细信息,但无法发送数据

<a class="dot"  style="top:110px;  left:145px;" continent="NA"  id="1"  name="1"></a>

我需要在单击时显示弹出对话框 但单击后对话框不会打开

    <script language="javascript" type="text/javascript">
$('a.dot').click(function(){
var vid=$(this).attr('id');
var vname=$(this).attr('name');
var vcity=$(this).attr('city');
$.ajax({
type : GET,
data:{id : vid , name : vname , city : vcity},
url : "ajax.php",
success : function(data){
$('#dialog-message').html(data);
}

});
});
</script>

<a class="dot" style="top:110px; left:145px;" continent="NA" id="1" name="1" city="teh"></a>

<div id="dialog-message">
</div>

$('a.dot')。单击(函数(){
var vid=$(this.attr('id');
var vname=$(this.attr('name');
var vcity=$(this.attr('city');
$.ajax({
类型:GET,
数据:{id:vid,name:vname,city:vcity},
url:“ajax.php”,
成功:功能(数据){
$('#对话框消息').html(数据);
}
});
});
php代码是:

if(isset($_GET)){
echo '<script>
    $(function() {
        $( "#dialog-message" ).dialog({
            modal: true,
            buttons: {
                Ok: function() {
                    $( this ).dialog( "close" );
                }
            }
        });
    });
    </script>
    <div id="dialog-message">
   ' . $_GET[name]  . ',' . $_GET[id] . ',' . $_GET[city] . '
    </div>
';
}
if(isset($\u-GET)){
回声'
$(函数(){
$(“#对话框消息”).dialog({
莫代尔:是的,
按钮:{
好的:函数(){
$(此).dialog(“关闭”);
}
}
});
});
“.$”获取[姓名],“.$”获取[身份],“.$”获取[城市]。”
';
}
类型:“获取”不是类型:获取

ajax.php

if(isset($_GET)){
echo  $_GET[name]  . ',' . $_GET[id] . ',' . $_GET[city] ;
}
if(isset($_GET)){
echo  $_GET[name]  . ',' . $_GET[id] . ',' . $_GET[city] ;
}

您的PHP代码似乎正在另一个
内部创建一个
。尝试更改PHP生成内容的
id
,并更改PHP中的脚本以匹配新的
id

Ajax。get可以轻松完成这项工作:

//This is a Click even. It fires when you click the (<a class="dot">CLick</a>)
<script language="javascript" type="text/javascript">

$(document).ready(function() {

$('.dot').click(function(){

var vid=$(this).attr('id');

var vname=$(this).attr('name');

var vcity=$(this).attr('city');

$.get("ajax.php?id="+ vid +"&name="+ vname + "&city=" + vcity, function(data){

    $('#dialog-message').html(data);

    $( "#dialog-message" ).dialog({

            modal: true,
            buttons: {
                Ok: function() {
                    $( this ).dialog( "close" );
                }
            }
        });

    });
});
});

</script>



//This is a load even. It fires when the page is loaded
<script language="javascript" type="text/javascript">

$(document).ready(function() {

var vid=$(this).attr('id');

var vname=$(this).attr('name');

var vcity=$(this).attr('city');

$.get("ajax.php?id="+ vid +"&name="+ vname + "&city=" + vcity, function(data){

    $('#dialog-message').html(data);

    $( "#dialog-message" ).dialog({

            modal: true,
            buttons: {
                Ok: function() {
                    $( this ).dialog( "close" );
                }
            }
        });

    });

});

</script>

    <a class="dot" style="top:110px; left:145px;" continent="NA" id="1" name="1" city="teh">Click Here</a>

    <div id="dialog-message" style="display:none;">
    </div>

您是否收到PHP或JavaScript返回的任何错误?另外,到目前为止,
中绘制了什么?您的ajax现在工作得非常好,请参见console.add alert(data);在$('#对话框消息').html(数据)之前;您还必须使用$('#对话框消息').show()显示div;当我在$('#对话框消息').html(数据)之前使用警报时;显示真实但问题不是显示jqueryui对话框?!怎样才能修复?如何在jqueryui对话框中显示数据?我检查了你的代码,你犯了很多错误。您需要决定如何触发事件。检查我的代码,您将看到您可以使用的两种类型的事件。我编辑了我的代码。你应该只使用一个。您已经在代码中使用了这两种方法。
if(isset($_GET)){
echo  $_GET[name]  . ',' . $_GET[id] . ',' . $_GET[city] ;
}