Jump to content

using JQuery .load inside js function


dotkpay

Recommended Posts

Hello,

 

I have been trying to use a js function to call the jquery load utility.

 

This helps me prevent multiple load items on the same page since the single load will be using variables passed on from html.

 

So incase I have a page like the one below, how do I go about this...

 

<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<button id="button">click</button>

<div id="area"></div>

<script type="text/javascript">
$(document).ready(function() {
$('#button').click(function() {
$('#area').load('example.html');
});
});
</script>

</body>
</html>

 

Place your own file in the example.html spot

 

Thanks in advance

Link to comment
Share on other sites

var something, something_else, another_thing, path;
if(something == something_else)
{
  path = "something.html";
}
else if(something == another_thing)
{
  path = "another_thing.html";
}
else
{
  path = "default.html";
}

$('#area').load(path);

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.