1

EDIT 2

I still need help, as the error still isn't fixed. Below I have added a link to a screenshot of what .ajaxError() does throw:

https://i.stack.imgur.com/hYAp0.jpg

Another thought was the server setting. Is there any chance that suphp or the mpm_itk module are the cause for this bug?

EDIT

I have figured out something. My Ajax-Call should update some data from an input and a textarea. I tested some more and saw that the 403 only occurs when the value of my textarea or the value of my input has more than one whitespace ... So 'that-is-a-test' and 'thatisatest' work fine, but 'that is a text' returns a 403.

I also want to add that the Ajax-Call is done with a get-method.

Original

I've got a problem working on my cakePHP project. First of all I have to say that I am new to cakePHP and that I work on a project that was not developed by me initially.

I have set up this project on my localhost (Windows 8 with xampp) and everything works fine.

In a next step I edited the Bootstrap-Configuration file, corrected the database information and uploaded all files to my server.

Now everything still works, except for the jQuery AjaxCalls. Tracing the root of this error I saw that the server returns an 403 Status Code.

Now I searched for possible reasons. First aspect I found was to set the security-level from high to medium. But as my 2.x project does not have this setting anymore, I need another solution.

Next step was to check the server settings. But the phpinfo of both, my local version and the server where the error takes place, seem to be nearly the same. Only the PHP version of 5.3 on the server and the use of FastCGi are different. But as cakePHP do not need more than 5.2 that cannot be the reason.

So now I have no idea what to search for. I think it has to be one setting because it works fine on my localhost, worked fine on another server but fails on the new server. Any ideas I could check? As I am not an expert of server technologies it would be great if you answer as detailed as possible.

thanks and greets

1 Answers1

1

I have now changed my jQuery Ajax-Call that looks like following

    $.ajax({
        url: '/metas/saveMetas',
        data: {
            "model": model,
            "f_key": f_key,
            "pagetitle": pagetitle,
            "keywords": keywords,
            "description": description,
            "niceurl": niceurl
        },
        dataType: 'json',
        complete: function(){
            return false;
        },
        success: function(result) {
            if(typeof result =='object') {
                $('#modal-spinner-seo-update').hide('slow');
                jQuery.each(result, function(field, message) {
                    $('#seo-'+field).next('div.error-message').html(message).fadeIn('fast');
                });
            } else {
                $('#modal-spinner-seo-update').hide('slow', function() {
                    $("#seo-widget-message-success").fadeIn('slow').delay(2000).fadeOut('slow');
                });
            }
            return false;
        }
    });

into a simple JavaScript xmlHttpRequest as following

    xhr = new XMLHttpRequest();
    xhr.onreadystatechange=function()
    {
        if (xhr.readyState==4 && xhr.status==200)
        {
            console.log(xhr.responseText);
            if(typeof xhr.responseText =='object') {
                $('#modal-spinner-seo-update').hide('slow');
                jQuery.each(result, function(field, message) {
                    $('#seo-'+field).next('div.error-message').html(message).fadeIn('fast');
                });
            } else {
                $('#modal-spinner-seo-update').hide('slow', function() {
                    $("#seo-widget-message-success").fadeIn('slow').delay(2000).fadeOut('slow');
                });
            }
            return false;
        }
    };
    xhr.open('GET','/metas/saveMetas?model='+model+'&f_key='+f_key+'&pagetitle='+pagetitle+'&keywords='+keywords+'&description='+description+'&niceurl='+niceurl, true );
    xhr.send();

and now everything seems to work fine. But I still do not understand why. Can anyone explain what I did wrong?