somejkuser
somejkuser

Reputation: 9040

changing ajax from get to post

Here is my original ajax query:

 var url = ajaxPath+ "?s=search&r="+resource+"&q="+query;
 $.getJSON(url,function(data){          

Here is my updated query:

$.getJSON(ajaxPath,{s:"search",r:resource,q:query},function(data){  

The updated one is not working for some reason. any ideas why?

Upvotes: 0

Views: 30

Answers (1)

T McKeown
T McKeown

Reputation: 12847

No where in your example are you specifying POST so GET will be used as default.

That $.getJSON() function get's converted to this, this is what I prefer as it is very clear:

$.ajax({
 dataType: "json",
 type: "POST",
 url: url,
data: data,
success: function(result,status,xhr){
 }
});

data would obviously be in the form of a JSON object.

Upvotes: 1

Related Questions