I write a countdown timer in jQuery and i need to keep some datas in a session when countdown ends. Datas have to be sent to server to update. How can i handle this situation. I am new in jQuery and asp.net so could you explain this briefly
Asked
Active
Viewed 281 times
2
-
7You should accept answers to your questions. – SLaks Jun 15 '10 at 15:53
4 Answers
0
If it's a one-way communication probably the quickest way is to call an aspx page using the $.get method:
http://api.jquery.com/jQuery.get/
something like this:
$.get('mypage.aspx', myData , function(result) {
alert('Ok');
});
where myData is a JSON object.
for more specific needs you can use the $.ajax method.

abatishchev
- 98,240
- 88
- 296
- 433

mamoo
- 8,156
- 2
- 28
- 38
0
Try using a PageMethod. You can create it in your codebehind and call it with jQuery. It's really fast & and great for countdown timers.
Make sure you enable PageMethods in your scriptmanager.
Call ASP.NET PageMethod/WebMethod with jQuery - returns whole page
0
Supose you have a class like this:
public class MyClass
{
public string FirstName { get; set; }
public string LastName { get; set; }
}
And an action method like this:
public JsonResult Test(string data)
{
// do something with data
var obj = new MyClass {FirstName = "Thiago", LastName = "Temple"};
return Json(obj);
}
Then you can write a js function using jquery like this:
$.get('<%= Html.Action("Test", "MyController")', {data: "some value"}, function(result){
alert(result.FirstName + " " + result.LastName);
});
I hope this example is useful.

thitemple
- 5,833
- 4
- 42
- 67