I coded a website using Ajax and I want to compare clicked links to avoid page reloading.
My way to do it is having a var called Link and storing url into it.
Everytime I click on the #button, the url is stored into the Link,
then I call the CompareLink() function, then the GoToLink() function.
var Link;
$('#button').click(function() {
Link = http://myurl ;
CompareLink();
GoToLink();
}
I have trouble with the data comparison. I want to compare the OLD value of Link with the new Value, so I wrote a very vague approach (nonworking) and I wanted to know if somebody could help me.
function CompareLink() {
if ( Link == .data(Link)) {
//execute code
}
}
how about this?
and then
checkout this fiddle I made: http://jsfiddle.net/V9DyW/