如何让这个JSON响应跨域工作?

时间:2013-06-10 17:22:21

标签: json cross-domain jsonp

我有JSON响应工作,但无法让它跨域工作。如果有人能帮助我让这段代码工作,我将深表感激。这是工作页面,使用以下代码: http://highendwholesale.com/test.html

JSON:http://highendwholesale.com/json.php

<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1"> 
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $.ajaxSetup({ cache: false });
    $.getJSON("json.php", function(data){
        $('ul#myInventory').empty();

        $.each(data, function(index, d){           
        $('ul#myInventory').append('<li data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-li-has-thumb ui-btn-up-c">'+
            '<div class="ui-btn-inner ui-li">'+
                '<div class="ui-btn-text">'+
                    '<a href="#" class="ui-link-inherit">'+
                        '<img src="http://highendwholesale.com/listings/'+d.CID+'/thumb/1.jpg" height="80" width="80" alt="'+d.CID+'" class="ui-li-thumb">'+
                        '<h2 class="ui-li-heading">'+d.title+'</h2>'+
                        '<p class="ui-li-desc">'+d.blurb+'</p>'+
                    '</a>'+
                '</div>'+
                '<span class="ui-icon ui-icon-arrow-r ui-icon-shadow">&nbsp;</span>'+
            '</div>'+
        '</li>');
    });

        $('ul#myInventory').trigger("create");          
    }).error(function(jqXHR, textStatus, errorThrown){
        alert("error occurred!");
    });
    $('ul#myInventory').listview('refresh');         
});
</script>
</head>
<body>
<div data-role="page" id="index" data-theme="a">

    <div data-role="header">
        <h1>Inventory</h1>
    </div><!-- /header -->

<div data-role="content">   
    <div id="inventory">
        <ul data-role='listview' id='myInventory' data-inset='true' class='ui-listview ui-listview-inset ui-corner-all ui-shadow'></ul>
    </div>
</div><!-- /content -->

</div>
</body>
</html>

0 个答案:

没有答案