module: {
rules: [
{
test: /\.pug$/,
use: [
{ loader: 'file-loader', options: { name: '[name].html' } },
{ loader: 'extract-loader' },
{
loader: 'html-loader',
options: {
minimize: true,
removeComments: true
}
},
{
loader: 'pug-html-loader',
options: {
basedir: path.resolve(__dirname, '../src-ng')
}
}
],
}
]
}
$(document).ready(function () {
var xmlParse;
var xmlDoc = $.ajax({
type: "GET",
async: false,
url: "http://www.cbr.ru/scripts/XML_daily.asp",
dataType: "xml",
success: function (xml) {
xmlParse = $(xml).find('Valute');
}
});
console.log(xmlParse.text());
});
$(document).ready(function () {
xmlDoc().done(appendItem);
function xmlDoc() {
var dfd = new $.Deferred();
$.ajax({
type: "GET",
url: "http://www.cbr.ru/scripts/XML_daily.asp",
dataType: "xml",
success: function (xml) {
var xmlParse = $(xml).find('Valute');
dfd.resolve(xmlParse);
}
});
return dfd.promise();
}
function appendItem(xmlParse) {
xmlParse.each(function () {
$('#searchlist').append('<a href="javascript:void(0)" class="list-group-item">' +
$(this).find('CharCode').text() + ' (' +
$(this).find('Name').text() + ') => ' +
$(this).find('Value').text() + '</a>');
});
}
});
Google все умеет
// set POST variables
$url = 'http://api.pleer.com/token.php';
$userpwd = 'testclient:testpass '; // заменить на свои данные
$fields = array(
'grant_type' => 'client_credentials'
);
// url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
$fields_string = rtrim($fields_string, '&');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_USERPWD, $userpwd);
$result = curl_exec($ch);
curl_close($ch);
print_r('<pre>' . $result . '</pre>');