Files
sam-kd/estimate/test_ajax.html

43 lines
1.3 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html>
<head>
<title>AJAX Test</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<h1>AJAX Test for fetch_length_data.php</h1>
<div>
<label>Length:</label>
<input type="text" id="testLength" value="1000" />
<button onclick="testAjax()">Test AJAX</button>
</div>
<div id="result"></div>
<script>
function testAjax() {
const length = $('#testLength').val();
$.ajax({
url: 'fetch_length_data.php',
type: 'POST',
data: {
length: parseFloat(length),
rowIndex: 0,
inputType: 'area_length'
},
dataType: 'json',
success: function(response) {
console.log('Success:', response);
$('#result').html('<pre>' + JSON.stringify(response, null, 2) + '</pre>');
},
error: function(xhr, status, error) {
console.error('Error:', {xhr, status, error});
$('#result').html('<p style="color: red;">Error: ' + error + '</p><pre>' + xhr.responseText + '</pre>');
}
});
}
</script>
</body>
</html>