Link to home
Start Free TrialLog in
Avatar of WalterRR
WalterRR

asked on

Replace href with Javascript call

Hi,

I have a simple REST call as per below. I would like to replace the href with a javascript call so I can handle response codes. How can i best do this ?

<li class="btn btn-inverse"><a title=""  href="/rest/myService/handle"><i
					class="icon icon-share-alt"></i> <span class="text">Handle</span></a></li>

Open in new window


Thanks
W
Avatar of Gary
Gary
Flag of Ireland image

At the server? With Js at the client side? or...
Avatar of Zeickan
Zeickan

<script>
function mycall(API){

// Code here

}
</script>
....

<li class="btn btn-inverse">
    <a title=""  href="javascript:mycall('/rest/myService/handle');">
        <i class="icon icon-share-alt"></i> <span class="text">Handle</span>
    </a>
</li>

Open in new window


Or, if you are using jquery try this

<script>
$(document).ready(function() {
    $("a").click(function(){    
        var call = $(this).attr("href");        
        // code here        
        return false;    
    });   
});
</script>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial