0
HTML代碼:jQuery的AJAX調用會導致瀏覽器錯誤
<div class="clearfix" style="color: #555" style="display:block; ">
<input type="text" id="id_site" placeholder="nom-du-site" style="width: 245px; font-size: 16px;">
<div style="float: right; color: black; font-size: 16px; margin-top: 10px; margin-left: -6px">.domain.com</div>
</div>
<br>
<div class="spacing">
<a href="" id="envoyer" class="bouton">Envoyer</a>
下面是JavaScript代碼查詢Ajax調用:
$("#envoyer").click(function (e) {
// checks user input:
nom = document.getElementById('id_nom');
email = document.getElementById('id_email');
site = document.getElementById('id_site');
$.ajax({
url: 'http://localhost/website/script.php',
dataType: 'jsonp',
data: {
nom: nom,
email: email,
site: site
},
success: function (json) {
DataSeries = json;
},
error: branchAjaxFailed
});
});
這裏是script.php的(目前):
<?
if (isset($_GET["nom"])) $nom = $_GET["nom"];
if (isset($_GET["email"])) $email = $_GET["email"];
if (isset($_GET["site"])) $site = $_GET["site"];
?>
- Chrome無限期凍結。如果在此Ajax調用之後添加調試中斷,則Chrome永遠不會在「檢查元素」工具中進入調試中斷。
- IE給我一個「第2行堆棧溢出」錯誤。
任何人都可以看到什麼問題是?
螢火蟲,有一個淨標籤。擴展您的XHR請求並查看響應中的內容。 – Ashwin
沒有使用Ajax調用,PHP腳本是否正常工作? – nmford
@nmford是的PHP腳本直接在瀏覽器中調用時可以正常工作。 – tucson