jQuery AJAX request demo

HTML

<input type="text" value="http://example.com/image.jpg" id="myinput1" /> <a href="#" onclick="return getSuccessOutput();"> get url content </a>

CSS

a {
    padding: 0.2em;
}
a:hover {
    background-color: #02AAEE;
}
#output {
    display: block;
    margin-top: 8px;
    padding: 1%;
    border: 1px solid #666;
    background-color: #efefef;
    
}

JavaScript

// handles the click event, sends the query
function getSuccessOutput() {
   
    $.ajax({
        url:'/mypage.php?url='+ $('#myinput1').val(),
        complete: function (response) {
            alert("here is content");
            alert(response.responseText);
            // now here make codes to upload it
            alert("start upload script now..");
        },
        error: function () {
            alert('Bummer: there was an error!');
        },
    });
    return false;
}