Menu

How to create jquery ajax call in Asp.net

0 Comment

How to create Jquery ajax call in Asp.net

just add jquery in header.

<script src=’https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js’></script>

then add ajax call method in your header.

var data_string = ‘EmailId=’+ EmailId +’&IsChecked=’+ IsChecked;

$.ajax({
url:’UpdateUser’,
data:data_string,
type:’get’,
cache:false,
success:function(data){

alert(data);

},
error:function(){
alert(‘error’);
}
}
);

 

data_string is variable where you will write your data which you wants to send it server.
this article show you How to create jquery ajax call  Asp.net

$ sign is using in jquery. url is your .ashx file name where it will call and get the result.
data is which data your sending and success method giving you data from server side.

here is the example of .ashx file. ‘How to create jquery ajax call in Asp.net’ to the .ashx file.

when you willl create a .ashx file it will show you this like following code.

public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = “text/plain”;
context.Response.Write(‘send your data to client’);
}

context.Response.Write(‘send your data to client’); this line is allow you to send data to client side.

I hope you like this article “How to create jquery ajax call in Asp.net”.

 
Tags: , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *