Potney Switters
Potney Switters

Reputation: 3062

AJax call of URL within jquery

I am trying to simply invoke a URL like 'comment/comment_id/promote_to_front'. How do I do that? I've tried something like the following with no luck(this promotes a static id:13):

$.ajax({
  type : 'GET',
  url : 'comment/13/promote_to_front',
});

I do not want to to manipulate any returned data. Simply trying to call the url.

Upvotes: 0

Views: 99

Answers (2)

Arnaldo Capo
Arnaldo Capo

Reputation: 188

Add a callback function to get the data.

$.ajax({
    url: "comment/13/promote_to_front"
}).done(function(data) {
   //DO stuff with you data.
});

http://api.jquery.com/jQuery.ajax/

Upvotes: 1

PM.
PM.

Reputation: 1721

You have to pass other details sometimes, it's just a guess. If you can show the server side code then we can come to some conclusion, but anyways here are some additional things which you should try:

$.ajax({
        type: "POST",
        url: <your url>,
        data: <if any>,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg, textStatus, XMLHTTPRequest) {
           //Some Code
        },
        error: function (XMLHTTPRequest, textStatus, errorThrown) {
            //Some handler
        },
        cache: false
    });

It has lots of extra thing, which you even dont want, just try to add the options one by one.

Upvotes: 2

Related Questions