Solved

jquery java

Posted on 2013-02-02
9
212 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
ID: 38846503
0
 

Author Comment

by:doctorbill
ID: 38846619
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
ID: 38846634
0
 
LVL 52

Assisted Solution

by:Julian Hansen
Julian Hansen earned 500 total points
ID: 38846637
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:doctorbill
ID: 38846657
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 52

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 38846731
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
ID: 38846804
perfect - thanks a lot
0
 

Author Closing Comment

by:doctorbill
ID: 38846807
solved
0
 
LVL 52

Expert Comment

by:Julian Hansen
ID: 38846854
You are welcome - thanks for the points.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

919 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

18 Experts available now in Live!

Get 1:1 Help Now