How to consuming SOAP XML from jquery using jquery SOAP? - javascript

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>

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>

Loging into a site using a XMLHttpRequest

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>

handontable is returning blank for my JSON. How do I fix it?

I am using handsontable and getting a stream of json objects. When i parse it and load it into handontable, i only get a blank div container. How do i fix it?
For some reason that i dont understand data1 in line 33 becomes empty in line 38
<!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="https://cdn.jsdelivr.net/npm/handsontable#7.1.1/dist/handsontable.full.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/handsontable#7.1.1/dist/handsontable.full.min.css" rel="stylesheet"
media="screen">
</head>
<body>
<h1> hello world</h1>
<script src="jquery-3.4.1.js"></script>
<script>
$("h1").css("color", "blue");</script>
<div id="example"></div>
<div id="example1"></div>
<script>
var data1 = new Array()
var url = "https://api.myjson.com/bins/6ysob";
fetch(url).then(function (response) {
response.json().then(function (parsedJson) {
data1 = parsedJson;
})
});
var container1 = document.getElementById('example1');
console.log('This is the parsed json', data1);
var hot = new Handsontable(container1, {
data: data1,
rowHeaders: true,
colHeaders: true,
filters: true,
dropdownMenu: true
});
</script>
</body>
</html>
this is not weird that data1 is empty at line 38 because this line is execute before the callback of the fetch you have to do this :
<!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="https://cdn.jsdelivr.net/npm/handsontable#7.1.1/dist/handsontable.full.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/handsontable#7.1.1/dist/handsontable.full.min.css" rel="stylesheet"
media="screen">
</head>
<body>
<h1> hello world</h1>
<script src="jquery-3.4.1.js"></script>
<script>
$("h1").css("color", "blue");</script>
<div id="example"></div>
<div id="example1"></div>
<script>
var data1 = new Array()
var url = "https://api.myjson.com/bins/6ysob";
fetch(url).then(function (response) {
response.json().then(function (parsedJson) {
data1 = parsedJson;
var container1 = document.getElementById('example1');
console.log('This is the parsed json', data1);
var hot = new Handsontable(container1, {
data: data1,
rowHeaders: true,
colHeaders: true,
filters: true,
dropdownMenu: true
});
})
});
</script>
</body>
</html>
(I recommend you to check some articles on Promise behavior in js)
I recommend you to take a look at this code (better readability) :
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!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="https://cdn.jsdelivr.net/npm/handsontable#7.1.1/dist/handsontable.full.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/handsontable#7.1.1/dist/handsontable.full.min.css" rel="stylesheet"
media="screen">
</head>
<body>
<h1> hello world</h1>
<script src="jquery-3.4.1.js"></script>
<script>
$("h1").css("color", "blue");</script>
<div id="example"></div>
<div id="example1"></div>
<script>
let url = "https://api.myjson.com/bins/6ysob";
fetch(url).then( resp => resp.json() ).then( json => {
let container1 = document.getElementById('example1');
let hot = new Handsontable(container1, {
data: json,
rowHeaders: true,
colHeaders: true,
filters: true,
dropdownMenu: true
});
});
</script>
</body>
</html>

Import/export implementation using Handlebars and Node.js/Express

I am trying to implement import/export using handlebars with nodejs/express. For some reason it gives me the following error Uncaught SyntaxError: Unexpected token {
File - api.js
import { getSymbolDb, executeEnterKey } from './fetchData'
const symbolTags = document.querySelector('#symbolTags')
const requestSymbol = document.querySelector('#requestSymbol')
requestSymbol.addEventListener('click', getSymbolDb)
symbolTags.addEventListener("keyup", executeEnterKey)
document.addEventListener('DOMContentLoaded', getSymbolDb)
File - fetchData.js
export function getSymbolDb() {}
export function executeEnterKey(event) {}
HTML File
<!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>
</head>
<body>
{{{body}}}
<script src="/JS/api.js"></script>
<script src="/JS/fetchData.js"></script>
</body>
</html>
Solution
Here you will find more information on the subject. The following code is the basic example you can start with.
File - api.mjs
import { getSymbolDb, executeEnterKey } from './fetchData.mjs'
const symbolTags = document.querySelector('#symbolTags')
const requestSymbol = document.querySelector('#requestSymbol')
requestSymbol.addEventListener('click', getSymbolDb)
symbolTags.addEventListener("keyup", executeEnterKey)
document.addEventListener('DOMContentLoaded', getSymbolDb)
File - fetchData.mjs
export function getSymbolDb() {}
export function executeEnterKey(event) {}
HTML File
<!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>
</head>
<body>
{{{body}}}
<script type="module" src="/JS/api.mjs"></script>
<script nomodule src="fallback.js"></script>
</body>
</html>

Angular view doesn't show for a ui-router state with no url

I'm trying to display some view, on any calling URL.
$stateProvider.state('test', {
url: '',
views: {
'testView#' : {
templateUrl: '/app/test/test.html',
controller: 'test.controller',
controllerAs: 'testVM'
}
}
});
I've tried url: '' and with no url attribute, but my view is never displayed. It only works when it has a specific url like url: '/'
Here is my index.html
<!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">
<title>Mock App</title>
<!-- Import additional "vendor" css here -->
<link rel="stylesheet" href="resources/styles/bundle-GENERATED-VERSION.min.css">
</head>
<body>
<h1>Test</h1>
<div data-ui-view="testView"></div>
<script src="app/bundle-GENERATED-VERSION.min.js"></script>
</body>
</html>
How can I do this ?
If you want to match every url that starts with /
you can try something like url:'/*path'
https://github.com/angular-ui/ui-router/wiki/URL-Routing#regex-parameters

Categories

Resources