tags:

views:

69

answers:

2
function newPage(pagenum)
{
  /* load 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://ratingscorner.com/tempcollege

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

A: 

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.

patrick dw
@patrick - i had done that. it does not alert anything in IE.
pradeep
@pradeep - Do you get any errors in IE's developer tools? Any chance that you actually have a trailing comma after `pagenum` in your code?
patrick dw
@pradeep - So you get an `alert()`, but it is blank? Or you get no `alert()` popup at all?
patrick dw
@patrick - no pop up at all.
pradeep
@pradeep - So this is fixed now, right? You selected an answer, so I assume so.
patrick dw
@patrick - nope dude , still not working. it does not alert anything in IE
pradeep
@pradeep - If it's not fixed, you shouldn't select an answer. You clicked the checkmark next to the answer **gnarf** gave. Click it again, and I'll have another look.
patrick dw
@pradeep - I don't imagine that the `.html()` call has anything to do with it. But perhaps you could try it without that just to eliminate it as a potential problem.
patrick dw
@patrick - okie i did that. i will try solutions . you can check the live page at link i have given and see if you can find some errors
pradeep
@patrick - hey i was wrong . i think i was looking at cache earlier. when i alert(data). its getting the page. but not getting displayed in the div.
pradeep
@pradeep - Works for me in IE, but first I get `Object Expected submenu.js Line 2 Character 1` error. Make sure `submenu.js` is loaded **after** jQuery loads. Also, turn on debugging in IE's developer tools. You'll see the error.
patrick dw
@pradeep - Just got your other comment. So it is likely a display issue.
patrick dw
@patrick - does the page load in ur IE??if so whts ur IE version. i am using IE 6.0 .
pradeep
@pradeep - Your script appears in the middle of the page. It appears as though you are running the script **before** the `#data` element has been loaded. Place the script at the **bottom** of the page, or (preferably) wrap it in `$(function(){ // my code })`. I'll update my answer.
patrick dw
@patrick - hey if u see my code .. its as per u say <script type='text/javascript'>function newPage(pagenum){/* load page default from server - pass product name */$('#data').html("<div id='response'>Loading.....</div>").load('/college/college_change_temp.php',{product:'college',city:"<?php echo $city ?>",university:"<?php echo $university ?>",programmes:"<?php echo $programmes ?>",type:"<?php echo $type ?>",entrance_exams:"<?php echo $entrance_exams ?>",pagenum:pagenum});}$(document).ready(function(){newPage(0);}); but not working...
pradeep
@patrick - i did put newPage(0); at end of page .. but did not work.
pradeep
@pradeep - I see. The debugger cut off the end of the script, so I had to copy/paste it into my editor. I'll have another look.
patrick dw
@pradeep - Can you eliminate some of the HTML that is loaded? When you had an alert, I think I saw a script in there. Maybe there's an issue with that? Everything else looks good right now.
patrick dw
@pradeep - Also, I see that above the `#data` element, you have an element with the ID `#response`, but then you are creating another element with ID `#response` in your HTML call `.html("<div id='response'>Loading.....</div>")`. You can not have 2 elements with the same ID. I think this especially causes trouble in IE.
patrick dw
@patrick - i removed the extra div also. but no success found :(..any other idea ?
pradeep
@pradeep - Have you tried without this? --> `.html("<div id='response'>Loading.....</div>")` I don't know why that would make a difference, but who knows. Also, it is so much easier to debug if you organize your scripts into a separate file, rather than embedding them in the middle of your HTML.
patrick dw
@patrick - okie.will try that also.
pradeep
@patrick - i tries a simple code like $.post('/college/college_change_temp.php',{product:'college',city:"<?php echo $city ?>",university:"<?php echo $university ?>",programmes:"<?php echo $programmes ?>",type:"<?php echo $type ?>",entrance_exams:"<?php echo $entrance_exams ?>",pagenum:pagenum},function(data){$('#data').html(data);}); also then also did not work..
pradeep
@patrick - hey i tried to print just hello from back end and it printed it. but while printing whole data .its failing. any thing i should specifically check in php/css?
pradeep
@pradeep - You were definitely getting the data you requested since the `alert()` was popping up with the expected HTML. There must be some sort of markup error in the data. IE can be fickle. Try to simplify the HTML being returned, and narrow down the issue that way.
patrick dw
@patrick - i solved the problem . there was a div problem .
pradeep
@pradeep - Glad you got it working. :o)
patrick dw
@patrick - yup finally. Thanks for all your support.
pradeep
A: 

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.

hellozimi
@hellozimi - the same path works for FF. does its meaning different in IE?. okie i will correct the echo mistake and check
pradeep