无法发出Ajax发布请求

Sorry guys, there were problems in my php code. So it looks like ajax.status === 0 is usually a php or asp problem. Here you go:

I wrote

require_once($DOCUMENT_ROOT/"mysql.php");

instead of

require_once("$DOCUMENT_ROOT/mysql.php");

also I used

$mysql->user 

instead of

$mysql->username 

that I wrote in mysql.php [/edit]

Hi I'm calling two functions making ajax requests from inside a function loaded by window.onload and I always receive an ajax.status === 0 and a 500 internal network error when I try to make the request from companySponsors() (the other function ie. recordData() is working just fine). How can I deal with this situation?

window.onload = init;

function init() {
    "use strict";

    companySponsors();
    try {
        U.addEvent(U.I("paymentButton"), "click", calculate);
        U.addEvent(U.I("recordButton"), "click", recordData);
        U.addEvent(U.I("loanAmount"), "change", calculate);
        U.addEvent(U.I("interest"), "change", calculate);
        U.addEvent(U.I("repayment"), "change", calculate);
        U.addEvent(U.I("zipcode"), "change", calculate);
    } catch (err) {
        console.log("Error: " + err.name + " on file " + err.filename + " at line number " + err.lineno + " with message " + err.message);
    }
}

function recordData() {
    "use strict";

    var loanAmount = parseFloat(U.I("loanAmount").value);
    var interest = parseFloat(U.I("interest").value);
    var payments = parseFloat(U.I("repayment").value);
    var zipcode = U.I("zipcode").value;

    var ajax = getXMLHttpRequest();

    try {
        testAjax(ajax);
    } catch (err) {
        console.log("Error: " + err.name + " on file " + err.fileName + " at line number " + err.lineNumber + " with message " + err.message);
    }

    var url = "php/recordData.php";

    ajax.open("POST", url, true);
    ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

    ajax.onload = function () {
        if (ajax.status === 200) {
            if (ajax.responseText !== "
success
") {
                alert("Could not record the loan data");
            } else {
                alert("The loan data was successfully recorded");
            }
        }
    };

    ajax.send("amt=" + encodeURIComponent(loanAmount) + "&ai=" + encodeURIComponent(interest) + "&yrs=" + encodeURIComponent(payments) + "&zip=" + encodeURIComponent(zipcode));
};

function companySponsors() {
    "use strict";

    var ajax = getXMLHttpRequest();
    try {
        testAjax(ajax);
    } catch (err) {
        console.log("Error: " + err.name + " on file " + err.fileName + " at line number " + err.lineNumber + " with message " + err.message);
    }

    ajax.open("POST", "php/sponsors.php", true);
    ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");


    ajax.onload = function () {
        if (ajax.status === 200) {
            var lenders = JSON.parse(ajax.responseText);
            var list = "";
            for (var i = 0; i < lenders; i++) {
                var lender = lenders[i];
                list += "<li><a href='" + lender.url + "'>" + lender.name + "</a></li>";
            }
            U.I("ad").innerHTML = "<ul>" + list + "</ul>";
        }
    };

    ajax.send(null);
};