i am really new to the REST world, or in fact the WebApp side of java, so please don't mind if it's a silly question. I have a web page where pressing a button will call the following JS function:
function testFunction(){
        $(document).ready(function() {
            $.ajax({
                url: "http://localhost:8080/test/webapi/myresource",
                type: 'get',
                success: function (data) {
                    console.log(data)
                }
                });
        });
    }
where the above url is handled by my OWN web service(which is in java), that is the above GET will call the following Web Service:
@Path("myresource")
public class MyResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getIt() {
    return "Got it!";
}}
All i wanna do here is instead of returning "Got It", i wanna call another javascript function(dedicated to handle server kind of request) involving EXTERNAL rest call such as this:
        function externalResource() {
        $(document).ready(function() {
            $.ajax({
                url: "any_external_rest_call",
                type: 'get',
                dataType: 'json',
                success: function (data) {
                    document.getElementById('demo').innerHTML = "Perfect"
                }
                });
        });
    }
where i wanna return the data from the externalResource function to getIt() to finally the testFuntion(), i know its possible, but couldn't find much of the details online. It would be really helpful if someone could clear this up to me.
 
     
     
    