Solved

jquery java

Posted on 2013-02-02
9
210 Views
Last Modified: 2013-02-02
Please can someone give me full complete tutorials of how to open up content in a div on a php page from and existing hyperlink on that page

I need a complete tutorial and demo
I am happy with jquery / java or php

I have been trying for ages but cannot find a good example
0
Comment
Question by:doctorbill
9 Comments
 
LVL 30

Expert Comment

by:IanTh
Comment Utility
0
 

Author Comment

by:doctorbill
Comment Utility
To clarify
When I click on a link on a php page I want that link to open up the content (from a file or database) in a named div on that page
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
0
 
LVL 51

Assisted Solution

by:Julian Hansen
Julian Hansen earned 500 total points
Comment Utility
Assumes you have included jquery library
<!doctype html>
<html>
<head>
<title>Test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
  $('a.link').click(function(e) {
    e.preventDefault();
    $.get($(this).attr('href'),{},function(data) {
       $('#result').html(data);
    }
  });
})</script>
</head>
<body>
<a class="link" href="http://www.somewebsite.com">Click</a>
<div id="result"></div>
</body>
</html>

Open in new window

0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:doctorbill
Comment Utility
julianH

this script does not open the link in the div - it open it as a separate tab (webpage). I need the content to appear in the actual div
for example, I have made the div in your script 400 px wide. I need the content to occupy that width as a window on the same page
0
 
LVL 51

Accepted Solution

by:
Julian Hansen earned 500 total points
Comment Utility
That is because there is a missing ); in the script - see fixed script below.

<!doctype html>
<html>
<head>
<title>Test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
  $('a.link').click(function(e) {
    e.preventDefault();
    $.get($(this).attr('href'),{},function(data) {
       $('#result').html(data);
    }); // <= missing in original script
  });
})</script>
</head>
<body>
<a class="link" href="http://www.somesite.com">Click</a>
<div id="result"></div>
</body>
</html>

Open in new window

0
 

Author Comment

by:doctorbill
Comment Utility
perfect - thanks a lot
0
 

Author Closing Comment

by:doctorbill
Comment Utility
solved
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
You are welcome - thanks for the points.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now