Q:

How to run jQuery in my C# class? 

I have a ASP.NET MVC project and i want to use jQuery on them.  as other mention I put the jQuery on head section and found that they will work in firebug. 
Now I want to jQuery in my C# class.  how i can use them in C# class.  I want to run the code but it's never compile where I goes wrong. 
 public class Manager
    {
        public static void Test()
        {
          // i put here jQuery code but they never compiler i try many time. 
        }
    }

what is the right way to use jQuery in C# class.  like in javascript code is work if I write but in c# when I want to try something like ajax request. 
$.ajax is work fine in javascript but when I want to run them in C# they not compile.  What is the right way to send ajax request from c# class. 
Please tell me the way I can use jQuery ajax function in c# class. 

A:

The main reason you can't is because jQuery is a JavaScript library, not a C# library so it just won't work.  However, I'm not sure why you would want to do that.  
Your C# code is running server-side, so what does an AJAX request even mean in that context?  You are already running code on the server, there is no need to remotely contact the server over HTTP.  Just run whatever C# code you need to get the data you want.  Using AJAX would be kind of like trying to call yourself on the telephone to ask yourself something. 

A:

I think you have a fundamental misunderstanding of how the web works.   Javascript (JQuery is just a Javascript library) runs in the browser.   Your C# code runs on the server.   
The browser makes a request for a page from the server, which is your C# code (well, your code + whatever the ASP.NET MVC framework does for you) which sends a page to the client.   This page can include Javascript which the browser executes.   
Your server side code doesn't run Javascript (unless you're using a Javascript based server like Node. JS instead of ASP.NET).   It can output javascript for the browser to run, but it itself does not run it. 
Now as far making a AJAX request from C#, if you're trying to call something on your own site @JohnFx is correct that it would be pointless because you can just call the code directly without making a request. 
If you're trying to fetch data from an external site, you can make an HttpRequest from C# as shown here.   There may be some wrapper code that makes it easier to work with, but I don't know any off the top of my head (it's not something that's too commonly done).   You'll then need to figure out how to parse the response. 

A:

JQuery is a javascript library and therefore JQuery code cannot be put into your C# code.  In order for your JQuery to run, you must output it with the rest of your html and it will run in the users browser.   JQuery is javascript and cannot run on the server with your C# code.