Jquery Ajax在localhost(xammp)上工作但不在Server(cpanel)上工作?

时间:2014-05-29 19:53:04

标签: javascript php jquery ajax

Jquery Ajax在localhost(xammp)上工作正常,但不在Server(cpanel)上工作! 还有ajax与Javascript工作正常,但通过JQuery它有问题! (在服务器上) 我将发送方法更改为POST但问题相同。

这是我的网站: concert20.ir

这是js代码:

var arr=[];
function func1(id,status){
        var str;
        var a=id.split('-');
        // a[0] = chair number
        // a[1] = singer id
        // a[2] = place
        length=arr.length;
        if(status=='رزور شده')
        {
            // check that who resereved it?
            var index=jQuery.inArray(parseInt(a[0]), arr);
            if(index>=0)
            {
                // unreserved ...
                //arr[index]=-1;
                arr.splice(index, 1);
                length=arr.length;

                $.ajax({
                    url: 'ServerReply.php', 
                    type: "GET",
                    data: ({reservefunc:0,chairnum:a[0],singerid:a[1],place:a[2]}),
                    success: function(result){
                        $("#drawtable").html(result);
                    }
                });

                if(length==0)
                {
                    $.ajax({
                    url: 'ServerReply.php', 
                    type: "GET",
                    data: ({showdetails:0,chairnum:arr,singerid:a[1],place:a[2]}),
                    success: function(result){
                        $("#card").html(result);
                    }
                });
                }
                else
                {
                    $.ajax({
                    url: 'ServerReply.php', 
                    type: "GET",
                    data: ({showdetails:1,chairnum:arr,singerid:a[1],place:a[2]}),
                    success: function(result){
                        $("#card").html(result);
                    }
                });
                }
            }
        }
        else if(status=='قابل خرید')
        {

            // reserve ...
            arr.push(parseInt(a[0]));

            $.ajax({
                url: 'ServerReply.php', 
                type: "GET",
                data: ({reservefunc:1,chairnum:a[0],singerid:a[1],place:a[2]}),
                success: function(result){
                    $("#drawtable").html(result);
                }
            });  


            sts=$("input#checksts").val();
            if(sts==-1)
            {
                var index=jQuery.inArray(parseInt(a[0]), arr);
                arr.splice(index, 1);
                alert('این صندلی قبلا خریداری شده است');
            }
            length=arr.length;
            if(length==0)
            {
                $.ajax({
                    url: 'ServerReply.php', 
                    type: "GET",
                    data: ({showdetails:0,chairnum:arr,singerid:a[1],place:a[2]}),
                    success: function(result){
                        $("#card").html(result);
                    }
                });
            }
            else
            {
                $.ajax({
                    url: 'ServerReply.php', 
                    type: "GET",
                    data: ({showdetails:1,chairnum:arr,singerid:a[1],place:a[2]}),
                    success: function(result){
                        $("#card").html(result);
                    }
                });
            }
        }   
}

更新
我发现了问题!
服务器是上下文敏感的,我没有观察到它 我将 S erverReply.php更改为 s erverReply.php并且工作正常......

2 个答案:

答案 0 :(得分:0)

尝试将绝对URL保存写入var和comment中的url版本,分别取消注释

var mainurl = "http://localhost/project/serverReply.php"

var mainurl = "http://xeample.com/project/serverReply.php"

尝试是否可以解决问题

答案 1 :(得分:0)

试试这个:

$.ajax({
        type : "GET",
        url : "ServerReply.php",
        cache : false,
        async : true,
        global : false,
        data : {
                 "showdetails":0,
                 "chairnum":arr
            }
    }).done(function(msg) {
        //Do something
    });