var testDataVal;
$.ajax({
url: 'https://site.com/script.php',
method: 'get',
dataType: 'html',
data: {text: 'test'},
success: function(data){
let testData;
testData = JSON.parse(data);
console.log(testData);
testDataVal = testData;
}
});
console.log(testDataVal);
async function primer() {
var testDataVal = await $.ajax({
url: 'https://site.com/script.php',
method: 'POST',
dataType: 'JSON',
data: { text: 'test' }
});
console.log(testDataVal);
}
primer(); // Запускаем пример