I have this function, and every time I call it, I need the imagesUploadScript variable to be updated with a new URL. I've implemented in the server side a JSON response with the desired URL for each request, but I'm not able to get that JSON value with jQuery. 
$(function () {
      $('.editor').editorInsert({
        editor: editor,
        addons: {
          images: {
            imagesUploadScript: /* The url*/
          }
      });
    });
I have tried this, but doesn't seem to work :S
$.getJSON("/admin/upload_url",function(result){
                return JSON.stringify(result)
                              })
EDIT
I have restructured my code, this way my function accepts a callbacks as @Mohamad suggested and thanks to this question:
function getURL(callback) {
            var url;
            $.ajax({
                type: "GET",
                async: false,
                url: "/admin/upload_url",
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                success: function (data) {                            
                    url = data['url'];
                    callback(url);
                } //success
           });
        }
But I'm not able to return the url for imagesUploadScript but yes this way
getURL(function(url){
      console.log(url);
    });
I'm confused, how should I declare this function inside the other one so imagesUploadScript get's a new URL every time is called ?
Thanks in advance for any help ! :D
 
    