$.post 函数不起作用

$.post function doesnt work

本文关键字:不起作用 函数 post      更新时间:2023-09-26
function saveMe() {
    var strValues = "";
    var boxLength = document.choiceForm.choiceBox.length;
    var count = 0;
    if (boxLength != 0) {
        for (i = 0; i < boxLength; i++) {
            if (count == 0) {
                strValues = document.choiceForm.choiceBox.options[i].value;
            }
            else {
                strValues = strValues + "," + document.choiceForm.choiceBox.options[i].value;
            }
            count++;
        }
    }
    if (strValues.length == 0) {
        alert("You have not made any selections");
    }
    else {
        $.post("rolGridPermition.php", {
            rolId: strValues
        });
    }
}​

在此代码中 $.post 函数之间 否则偏执不起作用...有什么问题吗?谁能帮我?

正确使用 url,

$.post("http://yourdomain/rolGridPermition.php", {rolId: strValues }, function(data) {
    // code here
});

加载资源失败:服务器响应状态为 404(未找到(,表示 php 文件不在服务器中或 url 不正确。

如果你的脚本中包含jQuery,这应该可以工作。

$.post("rolGridPermition.php", {  rolId: strValues},function(result){
   alert(result);
});

请记住,由于跨域策略,您无法调用其他域中的页面。你仍然可以做一些技巧来完成它(使用jspnp作为数据类型(