0

I have checked the answers, and this is my first project with jQuery:

function LoadWPage(a, b) 
{ 
    // this line works - the PART is the (spare)part I want to show when selected
    document.getElementById("PART").innerHTML = "webshop.php?v="+a+"&p="+b; 

    // this is what I want to do, but nothing happens <------ my question
    $("#PART").load("webshop.php?v="+a+"&p="+b); 

    // this is a dummy div and it loads well - I get the data from the PHP page 
    document.getElementById("sonnich").innerHTML = '<object type="text/html" data="webshop.php?v=+'+a+"&p="+b+'" ></object>'; 

    // this simply leaves my div blank - why?
    //document.getElementById("PART").innerHTML = '<object type="text/html" data="webshop.php?v=+'+a+"&p="+b+'" ></object>'; // leaves it empty 
} 

so, I can get the page I need to load, and even show it. It just does not work in jQuery. I googled it but did not find any clear answers to my problem. The last line, which leaves it empty, I just dont get.

Any ideas?

WBR Sonnich

sonnich
  • 151
  • 2
  • 11
  • Have you included jquery itself? – u_mulder Nov 26 '15 at 20:21
  • I agree, check the console to see the logs. Your code is ok if you have included jQuery. Take look at this Fiddle: http://jsfiddle.net/blocknotes/7no6Lcya/ – Mat Nov 26 '15 at 21:52
  • Right... I tried the fiddle - it works (but I could not get the entire html to try locally). However, I made a simple html file, for testing locally - and it does not work on my computer, but it works on other computers. When I upload it to somewhere (or use localhost....), and run it from there it works, but with very different results in chrome and IE. IE is ok, but Chrome adds ~10
    to the load, so my single line is followed by empty space The page I am working still does not work, I am still trying to figure that out
    – sonnich Nov 29 '15 at 10:40

1 Answers1

-2

The easiest way to test is to dump the entire jQuery library on top of your function. Copy & paste from https://code.jquery.com/jquery-2.1.4.min.js

This way, we know for sure jQuery is injected. Of course this is not a permanent solution, and just helps you narrow down your bug.

If it works, then you know your aren't injecting in jQuery. If it doesn't work, then something else is up.

*** if you are neat, you can use a function that inject in jQuery in your javascript Injecting jQuery into a page fails when using Google AJAX Libraries API

Cheers,

Community
  • 1
  • 1
wonghenry
  • 575
  • 2
  • 6
  • 18