开发者

jquery load function not working

function newPage(pagenum)
{
  /* 开发者_如何学Goload page default from server - pass product name */
  $('#data').html("<div id='response'>Loading.....</div>").load(
    '/college/college_change.php',
    { product:'college',
      city:"<?php echo $city ?>",
      university:"<?php echo $university ?>",
      programmes:"<?php $programmes ?>",
      type:"<?php echo $type ?>",
      entrance_exams:"<?php echo $entrance_exams ?>",
      pagenum:pagenum
    });
}

you can just check the code / page at http://abc.com/tempcollege

I am using this load function, it works well in most browsers, but in IE it does not load the data.


Are you certain it isn't loading? Could be that it is, but you have a layout glitch in IE that causes your data to not show. This is sometimes the case when an AJAX request seems to work in standards-compliant browsers, but not IE.

Try adding a callback to your load() with a simple alert() of the data returned. See if IE shows the data. If so, then it is some sort of layout issue.

$('#data').html("<div id='response'>Loading.....</div>")
          .load('/college/college_change.php',
                 {   product:'college',
                     city:"<?php echo $city ?>",
                     university:"<?php echo $university ?>",
                     programmes:"<?php $programmes ?>",type:"<?php echo $type ?>",
                     entrance_exams:"<?php echo $entrance_exams ?>",
                     pagenum:pagenum
                 },
                 function(data) { alert(data) }  // Verify data received (or not)
               );

EDIT:

Be sure you wrap your jQuery code such that it runs after the DOM is loaded.

Either:

$( function() {
    // my jQuery code
});

Or:

$(document).ready( function() {
    // my jQuery code
});

They are effectively the same.


First, you forgot to echo the $programmes.

Second, when I use php to set variables in JavaScript I always declare the variables before I use them.

var theCity = '<?php echo $city; ?>';  

$([...]).load('/college/college_change.php/', {city: theCity},
function(r) {
    alert('done loading');
});

And are you sure you did the linking right to the php-script? It's easy to mess up with the slash in the beginning of the path string.

I hope this will be to any help.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜