views:

1655

answers:

3

Hi everyone! Ok, I have a very silly question to ask (which Im rather embaressed about I must admit!). Im using the nyroModal plugin for jQuery within an ASP.NET 3.5 WebForms app. Basically, let's say I have a hyperlink pointing to http://www.mysite.com/GetData.html?id=100

When the link is clicked, I want GetData.html to extract data from a database and populate some innerHTML elements with the return data. the querystring value will be extrcated using jqURL plugin for jQuery, and I will use jQuery's built-in Ajax function to make a call to a webservice passing in the id as a parameter.

My question is this: How do I use jQuery.Ajax() if this is not a POST method, but rather a GET method, from how I understand it? According to documentation, in order for $.ajax() to work, the type must be "POST".

Could someone please shed some light on this for me?

Thank you

A: 

jQuery.get() ?

Natrium
+2  A: 
$.ajax({
  type: "GET",
  url: "test.js",
  dataType: "script"
});

... from the first example in the jQuery docs.

David Dorward
+3  A: 

You have many options:

1- use the load method:

$('#container').load(("/page");

2-use the get command:

$.get('/page')

3-use the ajax command:

$.ajax({
type:'GET',
url:'/page',
success:function() {
}
})
Marwan Aouida
Yep, knew I was gonna feel silly asking this question! :)Ok, maybe I need to do a little more reading up on this. The impression I had (from a blog) was that you cannot return JSON data in ASP.NET if the type is not set to POST, which completely ruins the semantic definition of the HTTP verb IMO. Look, I DO have a lot more to understand, but could someone tell me - if I make a GET request to a w.service that is going to output paragraphs of text, what will it be returned as: JSON/XML/...?
Shalan