1
I am making an ajax request for an external URL and want to show only three elements of the original website on the page I developed.
But when executing the code it brings all the elements of the page.
From the page in question I want to show only the elements "User (user)" "Password (password)" and the button "Ok", as I do to show only these 3 elements on the page?
Note: I want to show the same elements and that when putting user and password and clicking OK it is directed to the original URL, follow the normal login flow.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Exemplo AJAX</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript" src="http://projetos.lucaspeperaio.com.br/ajax-cross-domain/jquery.xdomainajax.js"></script>
<script type="text/javascript">
$(function () {
$("#btn-ajax-jquery").click(function () {
$.ajax({
type: 'POST',
url: "http://www.site.com.br",
dataType: "html",
beforeSend: function () {
$("#resposta").html("Aguarde...");
},
success: function (data) {
$("#resposta").html(data);
},
error: function (err) {
console.log("Error: " + err.status);
console.log("Error Message: " + err.statusText);
}
});
});
});
function ajaxExecute() {
var result = document.getElementById("resposta");
var ajax;
// Instancia o AJAX
if(navigator.appName == "Microsoft Internet Explorer"){
ajax = new ActiveXObject("Microsoft.XMLHTTP");
}
else {
ajax = new XMLHttpRequest();
}
// Faz requisição
ajax.open("GET", "http://www.site.com.br", true );
ajax.onreadystatechange = function () {
if (ajax.readyState == 1) {
result.innerHTML = "Aguarde...";
}
if (ajax.readyState == 4) {
// Status OK
if (ajax.status == 200) {
// Exibe o resultado
result.innerHTML = ajax.responseText;
}
else {
// Em caso de erro mostra a mensagem
result.innerHTML = ajax.statusText;
}
}
}
ajax.send(null);
}
</script>
</head>
<body onload='ajaxExecute()'>
<h1>Exemplo Ajax</h1>
<div id="resposta"></div>
</body>
</html>