1

This question is in reference to

HTML - Change\Update page contents without refreshing\reloading the page

Since the question is protected, I cant go through it.

My question is whether or not something is missing because I can not get it to work. I have added the jquery library

<script language="JavaScript" type="text/javascript" src="js/jquery-1.9.1.js"></script>

I want to say that the function is not being called, but if I replace

$('#myStyle').load('data.php?id=' + id); 

with

document.getElementById("myStyle").innerText = 'text';

then it does work and i get text.

Another question is whether or not you could do this or something like it

document.getElementById("myStyle").innerText = '$('#myStyle').load('data.php?id=' + id)';

Thanks for your help Jeff

Community
  • 1
  • 1
Jeff Kyzer
  • 616
  • 2
  • 7
  • 14

2 Answers2

1

It looks like you're not using jQuery which is required to use the code in the question you linked to. You also need it to use the $ shortcut you referenced in your secind question. Start by adding it to your pages and then try the examples again.

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
John Conde
  • 217,595
  • 99
  • 455
  • 496
1

Do you use some other JavaScript libraries? Maybe other script/library uses/overrides $ (namespace, or whatever it is)?

Btw: get familiar with JavaScript debugger in your browser.

There is Dragonfly in Opera, Firebug in Firefox, DevTools in Chrome, IE has IE Developer Tools.

Kamil
  • 13,363
  • 24
  • 88
  • 183