开发者

Dynamic Content Loading with JQUERY

开发者 https://www.devze.com 2023-03-21 05:11 出处:网络
I\'m trying load a page dynamically with ajax.I pass along refid that i use to get the 开发者_开发问答page content.

I'm trying load a page dynamically with ajax. I pass along refid that i use to get the 开发者_开发问答page content.

All the information is stored in a custom attribute in the tag. There are 10+ links with their own values. RefID is very long. Not sure if that makes a difference.

<a href="#dPage" title="More Info" data-theme="c" lat="{value}" lon="{value}" refid="CnRiAAAA_wO24Cpr6mCxuLDmiXYmWB8GoC5AqCllosAfNUZbkxD3QeiLlldSgGAxiwFpIlEbMx1JxuM6J6-uvFCDA9C-NfMVxBkT438ylOSWm11b2S74qXngL-wYH29sm4KX48762VjhYov9G2oOPM_iQJRjBBIQiNyeosXXee4kwXLMYBBtChoUkQrLBokVPKDcRLehvs2PLVmDv68" id="detailslink"></a>
<div data-role="page" id="dPage">
        <div data-role="header">
            <h1>Details</h1>
        </div>
        <div data-role="content">
            <div id="detailspage">

            </div>
        </div>

    </div>

--

    $('#detailslink').live('click', function() {
        $("#detailspage").html('');
        var placelat = $(this).attr('lat'); 
    var placelon = $(this).attr('lon');
    var refid = $(this).attr('refid');
        $.ajax({  
               cache: false,
               url: "mobile/getdetails.php", 
               dataType: "html",
               data: "&lat="+placelat+"&lon="+placelon+"&refid="+refid,
               success: function (data) {   
                    alert("Success");
                    $("#detailspage").html(data);
                },
                error: function(jqXHR, textStatus, errorThrown) {
                    alert(textStatus);
                }

            });
        //alert("done");

    });

This doens't work properly on the iPhone. The content is returned and works fine in chrome, firefox, safari, android, but not iphone.

The iphone does not show anything. It looks like it does make the call but nothing on the page.

Stuck on this.

Thanks in advance.


Are you including the js file using a relative path? Is the php called getdetails.php or getDetails.php?


Are you sure that the success function is being called on the iPhone? Tried putting an alert in there to check? Just wondering if there's an error occurring that you're missing.

Edit: Add an error function to the call. If it's failing, you'll hopefully find out why.

jQuery Ajax() method docs


I switched my includes from

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4/jquery.mobile-1.0a4.min.css" />
<script src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a4/jquery.mobile-1.0a4.min.js"></script>

to

<link href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<script src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script>

And now it works.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号