-3

I have C# page with 2 functions - 1 to get data from my MSSQL database, and the second one to insert data into it.

I want to know how to use AJAX (or any other way?) to call this functions from JS file. For one of the functions i only need to get data back, for the other one i need to send data from the JS to the C# functions..

jta
  • 3
  • 2
  • http://stackoverflow.com/questions/10653637/jquery-ajax-post-to-c-sharp use this link – Ajay Kumar Apr 26 '15 at 10:43
  • 1
    seams you will need to go through some articles or tutorials before going forward, or at least see some fast examples, start by google "jquery ajax with c#" – Amr Elgarhy Apr 26 '15 at 10:44

1 Answers1

0

I believe you are using jQuery based on your tags.

To send a GET request in jQuery:

$.get("myUrl", function(data) {
   console.log(data);
});

data contains the content of myUrl - if the content is json, it will be a PlainObject, if not it will be a string.

To send a GET request with parameters in jQuery:

$.get("myUrl", {"param1":"content","param2":"content"}, function(data) {
   console.log(data);
});

To send a POST request in jQuery:

$.post("myUrl", {"param1":"content","param2":"content"}, function(data) {
   console.log(data);
});
Zudo
  • 481
  • 3
  • 19
  • thanks, but I don't understand how to get the result of a specific function. I entered my page url (Default.aspx) , and the data returned is the html of the page itself.. i wonder how i can get the result of a function i have in the code behind this aspx page.. – jta Apr 26 '15 at 12:32