Trouble with AJAX using GET

I am creating a event calendar. It works fine on our Intranet fine, but when I copy the plugin to an external site, I keep getting the following:

Sorry, that didn’t work. Please try again or come back later. 500 Error. Internal Server Error.

Here is the code that calls the function:

<button id="prev" class="button" onclick="getPrevmonth()"> < </button>

Here is the Javascript/AJAX function: (I used a couple alerts to make sure this was running fine, and it seems to be)

function getPrevmonth() {
            
    var currentmonth = document.getElementById('currentmonth').value;
    var currentyear = document.getElementById('currentyear').value;
    
    if (currentmonth) {
        if (currentmonth == 0) {
            var newmonth = 11;
            var newyear = currentyear-1;
        } else {
            var newmonth = Number(currentmonth) - 1;
            var newyear = currentyear;
        }
        alert("month set =" + newmonth);
    } else {
        var date = new Date();
        var month = date.getMonth();
        var year = date.getFullYear();
        
        if (month == 0) {
            var newmonth = 11;
            var newyear = year-1;
        } else {
            var newmonth = month - 1;
            var newyear = year;
        }
    }
    
    ( function( $ ) {
        $.ajax({
            type: "GET", // use $_GET method to submit data
            url: CalendarScript.pluginsUrl + '/events/processcalendar.php', // where to submit the data
            data: {
                newmonth : newmonth, // PHP: $_GET['newmonth']
                newyear  : newyear, // PHP: $_GET['newyear']
            },
            success:function(data) {
                $( '#calendardiv' ).html( data ); // add HTML results to empty div
                $( '#currentmonth' ).val( newmonth );
                $( '#currentyear' ).val( newyear );
            },
            error: function(req, textStatus, errorThrown){
                //alert('Ooops, something happened: ' + textStatus + ' ' +errorThrown);
                $( '#calendardiv' ).html( req.responseText );
            }
        });
    } )( jQuery );
}

Ans this is the processcalendar.php. I removed all the code and just put in something simple to test if it was something in this code, but it is still displaying the above error:

<?php
require_once('../../../wp-load.php');
global $wpdb;

$newmonth = $_GET["newmonth"];

echo $newmonth;

Any help or advice is appreciated. Thanks in advance.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

So, it turns out I’m an idiot. For some reason, Aptana changed what permissions files got uploaded with. I fixed that, and logged into the server to update the permissions on the files already uploaded, and it worked fine.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x