Javascript 航运计算器不工作
我当时正在使用这个网站的送货计算器。我在我的wordpress的根目录下添加了以下代码Javascript 航运计算器不工作,javascript,php,wordpress,function,shipping,Javascript,Php,Wordpress,Function,Shipping,我当时正在使用这个网站的送货计算器。我在我的wordpress的根目录下添加了以下代码 <?php $zip = ""; $weight = ""; $qty = ""; if (isset($_GET['z'])) { $zip = $_GET['z']; } if (isset($_GET['w'])) { $weight = $_GET['w']; } if (isset($_GET['q'])) { $qty = $_GET['q']; } $site_url = "htt
<?php
$zip = "";
$weight = "";
$qty = "";
if (isset($_GET['z']))
{
$zip = $_GET['z'];
}
if (isset($_GET['w']))
{
$weight = $_GET['w'];
}
if (isset($_GET['q']))
{
$qty = $_GET['q'];
}
$site_url = "http://www.marketumbrellasite.com/GetRate.aspx?w=".$weight."&q=".$qty."& z=".$zip;
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $site_url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
ob_start();
curl_exec($ch);
curl_close($ch);
$result = ob_get_contents();
ob_end_clean();
if($result != "")
{
echo $result;
} else {
echo "An error occurred.<br>Please try again later.";
}
?>
当我点击它的时候,要计算的表单就来了,当我尝试这个邮政编码“85298”的时候。结果是找不到这个页面。我已经按照这个一样的东西工作了。我不知道我在哪里犯了错误。请一些人帮帮忙。谢谢 注意,您的Url是相对的,因此
/GetRate.php
将解析为绝对Urlhttp://yoursite/GetRate.php
(由于开头的/原因)
如果希望绝对Url为(例如)http://yoursite/portambrella/GetRate.php
,您应该将相对url更改为/portambrella/GetRate.php
看看这个:当你打开Firebug之类的web调试工具或Firefox或Chrome的内置工具时,会有一个“网络”选项卡,你可以用它来查看浏览器发出的HTTP请求 在本例中,您可以看到对的请求返回404NotFound错误 您的php文件
GetRate.php
可能位于其他位置,可能位于子文件夹中
你需要调整线路
var url = "/GetRate.php?z="+zip+"&w="+weight+"&q="+qty;
指向GetRate.php的正确URL
function loadRates() {
document.getElementById("ajaxloader").style.display = 'inline';
var zip = document.getElementById("zip").value;
var weight = document.getElementById("weight").value;
var qty = document.getElementById("qty").value;
var url = "/GetRate.php?z="+zip+"&w="+weight+"&q="+qty;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
document.getElementById("shipRateDiv").innerHTML = xmlhttp.responseText+" <br><br>";
document.getElementById("ajaxloader").style.display = 'none';
jQuery("#calcShipping").hide("slow");
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
[shipping-calculator weight="#"]
var url = "/GetRate.php?z="+zip+"&w="+weight+"&q="+qty;