简体   繁体   中英

ASP.NET with jQuery - POST vs GET

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

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() {
}
})
$.ajax({
  type: "GET",
  url: "test.js",
  dataType: "script"
});

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM