ajax sends GET request instead of POST

ajax sends GET request instead of POST

  

I running a javascript function when a button is clicked in my page. 


SyntaxEditor Code Snippet

function notificationClearAll(){
    $.ajax({
    method: 'POST',
    url: '"+GetRESTfulURL(Entities.REST_API.MarkAllRead, Session.MasterOfficer.MasterOfficer.UserId)+"',
    success: function(data) {
        $('#NotifList').html(data);
         $('#"+NotifCounter.Id+"').text(""-"");
        }
    });
}

However, when I check the browser console, an error is triggered whenever I click the button that will call the function above.

{"StatusCode":"405","Errors":["Invalid Verb: Method is not supported for this operation: GET"]}


What am I doing wrong? The REST API I am calling is called in the Preparation action since the screen has no UI. only function is to trigger the action inside the preparation.



Hi,


The property should be "type" instead of "method" if you are using the jquery that is included in the platform. "method" is only for versions 1.9+ of jquery.

For forward compatibility it's probably safer to include both arguments.


Regads,

João Rosado

João Rosado wrote:

Hi,


The property should be "type" instead of "method" if you are using the jquery that is included in the platform. "method" is only for versions 1.9+ of jquery.

For forward compatibility it's probably safer to include both arguments.


Regads,

João Rosado

 Hi, 

 Thanks for your reply. However, I already tried the "type" instead of "method" but it's still the same.