未捕获的TypeError:无法读取属性' jQuery17106389653570950031'

时间:2012-02-21 14:22:03

标签: php jquery-mobile

我从jQuery Mobile收到此错误:

02-21 22:30:02.730: E/Web Console(27077): Uncaught TypeError: Cannot read property 'jQuery17106389653570950031' of undefined at file:///android_asset/www/js/jquery.mobile.min.js:103 

为什么会发生这种情况?

这是我在index.html中的javascript。

    <!-- page voteParty -->
<div id="voteParty" data-role="page">
<script>
    //voteParty live
  $('#voteParty').live('pageshow', function(e){
console.log('voteParty live');
var party;

$.ajaxSetup ({  
        cache: false
});  

function getVoteParty(){
    $.ajax({
        type: "POST",
        url: "http://external.domain/getVoteParty.php",
        dataType: "json",   
        data: {user: currentUser},
        success: function(data){
            console.log('getVoteParty success with data '+data[0].party);
            $.each(data, function(key, value){
                //$('#candidateList').append('<li><a href="#party?party='+data[key].party+'"><img src="./'+data[key].image+'" /><h1>'+data[key].party+"</h1></a></li>")
                $('#candidateList').append('<li><a href="'+data[key].party+'"><img src="http://flatlens.kr/'+data[key].image+'" /><h1>'+data[key].party+"</h1></a></li>");
            });
            $('#candidateList').listview();
            $('#candidateList').listview('refresh');
        }
    });
}
getVoteParty();

$('#candidateList').delegate('li', 'click', function(e){
    party = $(this).find('a').attr('href');
    console.log(party);

});

$('#voteResponseForm').submit(function(e){
    event.preventDefault();
    event.stopPropagation();
    $.ajaxSetup ({  
        cache: false
    });  
    var ajax_load = "<center><img src='./img/ajax-loader.gif' alt='loading...' /></center>";
    $('#voteResponseLoading').html(ajax_load);
    $.ajax({
        type: "POST",
        url: "http://flatlens.kr/setVoteParty.php?callback=?",
        data: {user: currentUser, partynum: partyNum}, 
        dataType: "html", // no data returned
        success: function(html){
            event.preventDefault();
            event.stopPropagation();
            $('#voteResponseLoading').html('');
            //alert('setVoteResponse success');
            $('#voteAfterGuide').html('<center>투표가 정상적으로 처리되었습니다.<br />\'현재 상황\'에서 투표 결과를 확인하세요!<br /><br /><span id=\"voteResponse_second\"></span>초 후에 자동으로 창이 닫힙니다.</center>');
            var second = 3;
            var voteResponse_second = document.getElementById('voteResponse_second');
            voteResponse_second.innerHTML = second;
            var voteResponse_tid = setInterval(secondCount, 1000);
            function secondCount(){
                if(second>0){
                    second--;
                    voteResponse_second.innerHTML = second;
                }else{
                    clearInterval(voteResponse_tid);
                    voteComplete = true;
                    enable();
                    $.mobile.changePage('#dashboard', "slide");
                }
            }
        }
    });
});
});
   </script>

这是我的php文件。

    <?php
require 'JSON.php';
//mb_internal_encoding('utf-8');

$jsonInstance = new Services_JSON();

//header('Content-Type: text/html; charset=utf-8');
$con = mysql_connect("localhost", "username", "password");
mysql_select_db("flatlens");

//$user = iconv("UTF-8", "EUC-KR", $user); // because of global variables set to EUC-KR in PHP server, we must do this regardless of mb_internal_encoding.
$constituency = '';
global $json;
$user = $_POST['user'];

$sql = "SELECT * FROM flatlens_party";
 $resultParty = mysql_query($sql, $con);
  while($row = mysql_fetch_assoc($resultParty)){
foreach($row as $uv=>$uk) $row[$uv] = iconv("EUC-KR", "UTF-8", $uk); // because of global variables set to EUC-KR in PHP server, we must do this regardless of mb_internal_encoding.
    $output[] = $row;
}
$json = json_encode($output);
if($_GET['callback']){
echo $_GET['callback'].'($json);';
}else{
echo $json;
//echo $user;
}
mysql_close();
    ?>

我在GitHub上使用最新的jquery手机。基于2012年2月22日。

我想: 1. json需要改为jsonp

0 个答案:

没有答案