Why is my HTML not loading?

<script type="text/javascript">// <![CDATA[
$(document).ready(function() {
           var currentSemester;
           var currentCourseType;
           var href;
           /*Attach a submit handler to the form*/
          $("#coursesForm").submit(function(e) {
            e.preventDefault();
            currentSemester =$("#term option:selected").val();
            currentCourseType =$("#courseType option:selected").val();
            if(currentSemester == "all" || currentCourseType == "all")  {
              href = "../academics/all-core-courses.php";                       
              $.ajax({
               url:href,
               cache: false
              }).done(function(data){           
                var allSemesterCourses = $(data).find("div.featureBody");               
                $("div.results").html(allSemesterCourses.html());
              });
            }
            else {
                  href =  "/academics/" + currentSemester + currentCourseType + ".php";
                  $.ajax({
                    url:href,
                    cache: false
                  }).done(function(data){                       
                    var allSemesterCourses = $(data).find("div.featureBody");              
                    $("div.results").html(allSemesterCourses.html());
                  });               
           }
          });
         //by default loads all-core-courses page.
         href = "../academics/all-core-courses.php";                           
         $.ajax({
          url:href,
          cache: false
         }).done(function(data){           
           var allSemesterCourses = $(data).find("div.featureBody");                    
           $("div.results").html(allSemesterCourses.html());
         });                
   });
// ]]></script>

It’s either one of htese two lines (both if/else are failing at the bottom of the respective if/else)

            var allSemesterCourses = $(data).find("div.featureBody");              
            $("div.results").html(allSemesterCourses.html());

featureBody exists in my HTML - I see it.

So does the results div. What am I doing wrong? No HTML is being loaded into the results div.

Nevermind. This appears to be related to my restricted network.

Try to use filter() instead of find()

Thank you, but it’s network restriction problems :slight_smile: .

I wouldn’t be familiar with that, at all. LOL! :smiley:

I actually have a different diagnosis (and I know this is correct.)

I took the working page, and madea test page in a restricted folder. It didn’t work. So I had ruled it restricted access of the network.

However, upon the CMS giving me the converted page in the restricted folder, it took out a key HTML div (feature[d]?Body) on all the other pages it’s supposed to load.

So screw this CMS messing with this page code…It’s the CMS’s fault for removing code; not the network being stupid!

1 Like

Why? Is there a common pitfall that occurs with find()? (I’m curious) :smile:

I’d say the pitfalls lie in filter, since it searches all the elements on the page and not just the children.

Looking at the code above, idk what effect filter would have in that context. Would it search the entire page? I think it would…

just in case :smile:

seriously, i had an similar issue with find() fixed later with filter()
but i’m can’t say who of them are better

1 Like

Cool. I was really just more curious, as I didn’t know if there was a reason :slight_smile: Thanks for coming back and explaining your experience with them. :smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.