0

私はこのようなリンクを持っています私は都市の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>

そして ajax.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>
';
}
4

3 に答える 3

0
   $(document).ready(function() {

    $('.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);
        $( "#dialog-message" ).dialog();
    }

    });
    });
    });

タイプ:"GET" NOT タイプ:GET

ajax.php

if(isset($_GET)){
echo  $_GET[name]  . ',' . $_GET[id] . ',' . $_GET[city] ;
}
于 2012-10-17T09:51:21.753 に答える
0

あなたの PHP コードは<div id="dialog-message">、別の の内部を作成しているよう<div id="dialog-message">です。PHP が生成する の を変更してみてid、新しい に一致するように PHP 内のスクリプトを変更してくださいid

于 2012-10-17T09:51:50.693 に答える
0

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>

ajax.php

if(isset($_GET)){
echo  $_GET[name]  . ',' . $_GET[id] . ',' . $_GET[city] ;
}
于 2012-10-17T09:56:53.213 に答える