36 lines
902 B
JavaScript
36 lines
902 B
JavaScript
|
function manipulateUrl() {
|
||
|
var url = $('#url').val();
|
||
|
|
||
|
$.ajax({
|
||
|
type: 'POST',
|
||
|
url: '../server/process.php',
|
||
|
data: { url: url },
|
||
|
dataType: 'json',
|
||
|
success: function (result) {
|
||
|
displayResult(result);
|
||
|
},
|
||
|
error: function (xhr, status, error) {
|
||
|
displayError(error);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function displayResult(result) {
|
||
|
console.log(result);
|
||
|
var resultContainer = $('#result-container');
|
||
|
resultContainer.empty();
|
||
|
|
||
|
if (result.hasOwnProperty('error')) {
|
||
|
resultContainer.append('<p class="error">' + result.error + '</p>');
|
||
|
} else {
|
||
|
// Update the text area with the modified URL
|
||
|
$('#url').val(result.after.replace(/&/g, '&'));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function displayError(error) {
|
||
|
var resultContainer = $('#result-container');
|
||
|
resultContainer.empty();
|
||
|
resultContainer.append('<p class="error">Error: ' + error + '</p>');
|
||
|
}
|