jquery .load not working

Hi,

I'm wondering why this (jQuery) bit of code isn't working:
(shown in the code snippet)

This code works fine which is just regular ajax (i.e. not using jquery):
   1. function revDescr(condition_id, rev_cat_id) {  
   2.     this.condition_id = condition_id;  
   3.     this.rev_cat_id = rev_cat_id;  
   4.  
   5.     //update the reverse entry description  
   6.     xmlhttp10=GetXmlHttpObject(); //if xmlhttp object not created  
   7.     if (xmlhttp10==null) {  
   8.         alert ("Browser does not support HTTP Request");  
   9.         return;  
  10.     }  
  11.  
  12.     var url="./include_ajax/updateRevDescrSi.php";  
  13.     url=url+"?condition_id="+this.condition_id;  
  14.     url=url+"&rev_cat_id="+this.rev_cat_id;  
  15.     url=url+"&sid="+Math.random();  
  16.     xmlhttp10.open("GET",url,true);  
  17.     xmlhttp10.onreadystatechange=stateChangedRevDescr;  
  18.  
  19.     xmlhttp10.send(null);  
  20. }  
  21.  
  22. function stateChangedRevDescr() {  
  23.     if (xmlhttp10.readyState==4) {  
  24.         var data = xmlhttp10.responseText;  
  25.         document.getElementById("reverse_content").innerHTML = data;  
  26.     } else  {  
  27.         document.getElementById("reverse_content").innerHTML = "Please wait...updating";  
  28.     }  
  29. }  

I've displayed the code in it's beautified format on my blog here and if you wish to copy without the lines:
http://blog.tutorialref.com/javascript-tutorial/jquery-ajax-load-not-working-182.html

Thank you,
vkimura
function revDescr(condition_id, rev_cat_id) {
    this.condition_id = condition_id;
    this.rev_cat_id = rev_cat_id;
    
    var pars = 'condition_id='+this.condition_id+'&rev_cat_id='+this.rev_cat_id; //used by jQuery
    $("#reverse_content").load("updateRevDescrSi.php?"+pars);
 }

Open in new window

Victor KimuraSEO, Web DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
the element with id='reverse_content' will need to have innerHTML support if the updateRevDescrSi.php is returning HTML content. What elemeint has  id='reverse_content'?
0
Victor KimuraSEO, Web DeveloperAuthor Commented:
Hi hielo,

I think this was a similar problem to the other post. I was using block-level <p> tags and as you said IE doesn't allow other block-level tags. However, I'm wondering if I had to place elements within <select> or <option> via ajax or jquery .load. How would I make it work?

Thanks,
Victor
0
Victor KimuraSEO, Web DeveloperAuthor Commented:
Actually, I just test the jquery .load and it doesn't work even when I changed the <p> tag to a <div> tag. The pars are being passed both in IE and firefox as I viewed them in their respective debuggers.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

hieloCommented:
>>However, I'm wondering if I had to place elements within <select> or <option> via ajax or jquery .load. How would I make it work?
I typically designate a container span OR div and have the complete HTML markup for the list (<SELECT...>...</SELECT>) returned as the responseText and then insert that in the span or div (depending on what I chose as the container element) using .innerHTML

>>Actually, I just test the jquery .load and it doesn't work even when I changed the <p> tag to a <div> tag. The pars are being passed both in IE and firefox as I viewed them in their respective debuggers.
Where's your  page/url?
0
Victor KimuraSEO, Web DeveloperAuthor Commented:
Here are the pages:

This link uses regular AJAX javascript (i.e. not jQuery):
http://cosmeticguide.com/dev_3/reverse_otc.php

This link (which is a striped down version of the first) uses jQuery but the data isn't displaying in both IE and firefox:
http://cosmeticguide.com/dev_3/reverse_otc2.php

Thank you,
vkimura
0
Steve KrileCommented:
Without testing, I'm not sure this will be helpful to you, but I've learned the hard way that concatenating strings INLINE with jquery leads to unexpected results - that is, in some circumstances the code works and others it doesn't.

Have you:

1.  Tested .load() with a simple example like:  
      $("#reverse_content").load("test.html");

Where test.html is some very simple content.

2. Tested .load() with a fully concatenated version of your URL

    var pars = 'updateRevDescrSi.php?condition_id='+this.condition_id+'&rev_cat_id='+this.rev_cat_id;
    $("#reverse_content").load(pars);
0
Victor KimuraSEO, Web DeveloperAuthor Commented:
Hi skrile,

I have this code as above:

in regards to point (2).

I will test with a simple html page now though.
function revDescr(condition_id, rev_cat_id) {
    this.condition_id = condition_id;
    this.rev_cat_id = rev_cat_id;
    
    var pars = 'condition_id='+this.condition_id+'&rev_cat_id='+this.rev_cat_id; //used by jQuery
    $("#reverse_content").load("updateRevDescrSi.php?"+pars);
 }

Open in new window

0
Steve KrileCommented:
My point is, this code may not work:

$("#reverse_content").load("updateRevDescrSi.php?"+pars);


Because the "+pars" part may not be correctly parsed in jquery.

So, feed the .load() function the fully prepared URL like this:

    var pars = 'updateRevDescrSi.php?condition_id='+this.condition_id+'&rev_cat_id='+this.rev_cat_id;
    $("#reverse_content").load(pars);
0
Victor KimuraSEO, Web DeveloperAuthor Commented:
I just figured out that my relative url reference was wrong. So I changed that line to:

 $("#reverse_content").load("./include_ajax/updateRevDescrSi.php?"+pars);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Victor KimuraSEO, Web DeveloperAuthor Commented:
To skrile:
Oh, I see. Okay, good to know. I will try that in the future when I encounter a problem. Thank you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.