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 ?
Thanks
W
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>
Thanks
W
At the server? With Js at the client side? or...
<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>
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>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.