Jump to content

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
https://forums.phpfreaks.com/topic/260554-using-jquery-load-inside-js-function/
Share on other sites

The load method is the simplest way to grab data from the server, and it doesn't provide much flexibility.

You can use the jquery AJAX API and return an object with the various data that you want to inject, and inject it where you want.

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.