I'm making an ajax request for an external URL and I want to show only three elements of the original site on the page I've developed.
But when you run 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" and the "Ok" button, how do I show only these 3 elements on the page?
Note: I want to show the same elements and when I enter the username and password and click OK it will be 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><scripttype="text/javascript" src="http://projetos.lucaspeperaio.com.br/ajax-cross-domain/jquery.xdomainajax.js"></script><scripttype="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>