如何从页面源隐藏ajax url链接 [英] How to hide ajax url link from page sourse
本文介绍了如何从页面源隐藏ajax url链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从页面源中隐藏Ajax中的url,我该怎么办. 我的脚本(tracking.php)
I want to hide url in ajax from page source,how can i do it. my script(tracking.php)
<script>
$(document).ready(function () {
var from = "";
$('#loadings').show();
$.ajax({
type: "GET",
url: 'http://apis.andd.ddd/api/Get_Loadsheet_Details/<?php echo $number; ?>',
dataType: 'json',
success: function (response) {
$('#loadings').hide();
console.log(response);
document.getElementById('lrid').innerHTML = "LR NO: " + response[0].LRSUFIX + response[0].LR_NO;
document.getElementById('consign').innerHTML = response[0].COMPANY_NAME;
document.getElementById('from').innerHTML = response[0].LOADFROMMST;
document.getElementById('dest').innerHTML = response[0].DESTINATION;
document.getElementById('case').innerHTML = response[0].NO_OF_PKT;
document.getElementById('lrsta').innerHTML = response[0].LR_STATUS;
document.getElementById('lr').innerHTML = response[0].lrLoadStatus;
document.getElementById('vecno').innerHTML = response[0].VEHICLE_NO;
document.getElementById('lrstatus').innerHTML = response[0].LOADIG_STATUS;
document.getElementById('ldate').innerHTML = response[0].DATE;
}, error: function (errors) {
console.log(errors);//alert('hi');
$('#loadings').hide();
$('#error').html("<h2><span style='color:red;'>No data found on this LR No.</span></h2>");
}
});
});
</script
我的表单(index.html)
my form(index.html)
<form method="post" name="myForm" action="tracking.php">
<input type="text" name="number" id="number" placeholder="Enter LR Number" required>
<input type="submit" name="submit" value="Go">
</form>
请帮助我如何隐藏网址链接.
please help me how can i hide url link.
推荐答案
将请求发送到PHP,然后使用PHP调用API
Send the request to PHP, then make the call to the API with PHP
<script>
$(document).ready(function () {
var from = "";
$('#loadings').show();
$.ajax({
type: "GET",
url: 'somephp.php?number='<?php echo $number; ?>',
dataType: 'json',
success: function (response) {
.....
}, error: function (errors) {
console.log(errors);//alert('hi');
$('#loadings').hide();
$('#error').html("<h2><span style='color:red;'>No data found on this LR No.</span></h2>");
}
});
});
</script>
然后在您的PHP中
<?php
if (isset($_GET['number']) && is_int($_GET['number'])) {
$url = 'http://apis.andd.ddd/api/Get_Loadsheet_Details/' . $_GET['number'];
// make your request here
// send data back to Javascript
}
请参阅此帖子在PHP中调用REST API
这篇关于如何从页面源隐藏ajax url链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文