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
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.