Loging into a site using a XMLHttpRequest - javascript

I am learning curl and XMLHttpRequests i am trying to login to my telecom account, i have tried CURL and it works on other sites but i haven't been able to work this here is my code, please help
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
var toSend = {
_form_url:, //I took these params from capturing the request.
_success_url:,
_failure_url:,
msisdn:username,
password:"password"
}
var JSONstring = JSON.stringify(toSend);
var xhr = new XMLHttpRequest();
xhr.open('POST','https://www.three.co.uk/cs/form/customer-my3-login');
xhr.setRequestHeader('content-type', 'application/json');
xhr.Send(JSONstring);
</script>
</body>
</html>

Related

Java script google api to get authorization code

I done this code using tutorial but it does not work, it simply does open pop-up to enter your credentials for google. What is wrong with this code?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button id="sign-in-button">Sign in</button>
<script src="https://apis.google.com/js/api.js"></script>
<script>
gapi.auth2.init({
client_id: "655720894976-2rkkoov9efteqna8hq3vbc632brur2jf.apps.googleusercontent.com"
});
document.getElementById("sign-in-button").addEventListener("click", function() {
// Get an authorization code
gapi.auth2.getAuthInstance().grantOfflineAccess({
scope: "https://www.googleapis.com/auth/cloud-platform"
}).then(function(response) {
var authorizationCode = response.code;
});
});
</script>
</body>
</html>

How to close an html website using javascript?

So basically, I'm trying to create a system that closing the website when you get the password wrong. but I started to learn js just a couple of days ago and I don't know much of it yet.
here is the code:
<!DOCTYPE html>
<html id="web" lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MySite</title>
<script>
var web = document.getElementById("web");
var password = "BigDips12";
alert("Hey, For security messures and to make sure you are truly not a robot ...");
var security = prompt("Please enter the password here:");
if (security === password) {
alert('Welcome!')
} else {
alert('Password is wrong! The program will close itself now..')
function closeWin() {
web.close();
}
}
</script>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
I really need help pls
To close the browser tab use
window.close();
And u wasn't calling the function also
<!DOCTYPE html>
<html id="web" lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MySite</title>
<script>
function closeWin() {
window.close();
}
var web = document.getElementById("web");
var password = "BigDips12";
alert("Hey, For security messures and to make sure you are truly not a robot ...");
var security = prompt("Please enter the password here:");
if (security === password) {
alert('Welcome!')
} else {
alert('Password is wrong! The program will close itself now..')
closeWin()
}
</script>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>

How to consuming SOAP XML from jquery using jquery SOAP?

I'm trying connect my app to a SOAP web service XML, uso jquery SOAP (https://github.com/doedje/jquery.soap). The connection worked but I don't obtain data.
I attach my code (url, user and password are examples), Help me please.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="app/js/jquery.min.js"></script>
<script src="app/js/jquery.soap.js"></script>
</head>
<body>
<pre><code id="salida">...</code></pre>
</body>
<script>
$.soap({
url: 'http://myservice.com/sisWSAFI/Service.asmx',
method: 'GetSession',
data: {
user: 'user',
password: 'pass'
},
success: function(soapResponse) {
var respuesta = soapResponse.toString();
console.log(respuesta.GetSession);
},
error: function(SOAPResponse) {
// show error
}
});
</script>
</html>

make a redirect button in html with javascript

Here is the code I am attempting to use and embed in a Google Sites page:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Please follow the link below</title>
<script>
var urls = [
"http://www.kittenwar.com/",
'http://heeeeeeeey.com/',
'http://eelslap.com/',
'http://www.staggeringbeauty.com/',
'http://www.omfgdogs.com/',
'http://burymewithmymoney.com/',
'http://www.fallingfalling.com/',
'http://ducksarethebest.com/',
'http://www.republiquedesmangues.fr/',
'http://www.trypap.com/',
];
function goSomewhere() {
var url = urls[Math.floor(Math.random()*urls.length)];
window.location = url; // redirect
}
</script>
</head>
<body>
</body>
</html>
How do I make this work so that a button will appear in my Google Sites page that will randomly assign you to one of the listed array of links?
By adding a simple button and calling the javascript function. And you need to do some adjustments in your google sites account. You can refer this link to do the changes accordingly in your account.
http://www.thelandscapeoflearning.com/2014/05/did-you-know-google-sites-no-longer.html
AND
https://help.mofuse.com/hc/en-us/articles/226313408-Redirect-Setup-Google-Sites
var urls = [
"http://www.kittenwar.com/",
'http://heeeeeeeey.com/',
'http://eelslap.com/',
'http://www.staggeringbeauty.com/',
'http://www.omfgdogs.com/',
'http://burymewithmymoney.com/',
'http://www.fallingfalling.com/',
'http://ducksarethebest.com/',
'http://www.republiquedesmangues.fr/',
'http://www.trypap.com/',
];
function goSomewhere() {
var url = urls[Math.floor(Math.random() * urls.length)];
window.location = url; // redirect
}
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Please follow the link below</title>
</head>
<body>
<button onclick="goSomewhere();">Redirect</button>
</body>
</html>
In body
<button onclick="goSomewhere();">Click me</button>

API Foursquare javascript doesn't work

I'm trying to integrate Foursquare with my WebApp. I followed the instructions of Foursquare Developers Documentation but my app doesn't work(have the client ID, client Secret...)
Get the following error: "FoursquareClient not defined"
I have tried this:
the .html
<!DOCTYPE html>
<html DIR=ltr >
<head>
<title>Foursquare</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="viewport" content="width=320, initial-scale=1, minimum-scale=1, maximum-scale=1">
<script src="/html5/jquery-1.8.2.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/html5/foursquare.js"></script>
<script src="https://ss0.4sqi.net/scripts/third_party/jquery.ba-bbq-eddd4adf74d0c1310a401475178c57df.js" type="text/javascript"></script>
<script src="https://ss1.4sqi.net/scripts/apisamples-35608dc9c26343e74f5d99fc20bae6c5.js" type="text/javascript"></script>
</head>
<body onload="return viewFoursquareLoad(event)" >
<div data-role="page" id="viewFoursquare" >
<table id="viewFoursquare_table"><tr><td>
</td></tr></table>
</form></div>
</body>
</html>
and the foursquare.js:
function viewFoursquareLoad(event) {
var client = new FourSquareClient("<3PMAYEX2KZ11R25GWV4WVP0IYEVWU01NVP49890KHA5OWJ21VVB>", "<PRQKBBE0N0VBUQTQ5R2F1UFGEYFZ322ZNVLHO88991MHC3I0O0VI>", "<http://url.com.br>", "<remember_credentials>");
client.venuesClient.venues("<IHR8THISVNU>", {
onSuccess: function(data)
{
alert(data.response);
},
onFailure: function(data)
{
alert(data.response);
// the request failed
}
});
}
Try without all the angle brackets.
var client = new FourSquareClient("3PMAYEX2KZ11R25GWV4WVP0IYEVWU01NVP49890KHA5OWJ21VVB", "PRQKBBE0N0VBUQTQ5R2F1UFGEYFZ322ZNVLHO88991MHC3I0O0VI", "http://url.com.br", "remember_credentials");
and
client.venuesClient.venues("IHR8THISVNU", {

Categories

Resources