Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing ASP.NET Server variables in jQuery

Tags:

jquery

asp.net

In Page_Load() function, I have populated an arraylist and a hashtable. I need to read their values in the $(document).ready(function(){...}.

I am a beginner in terms of ASP.NET and jQuery. Please suggest a way to do it.

cheers

like image 435
Arnkrishn Avatar asked Dec 20 '09 05:12

Arnkrishn


1 Answers

you can use PageMethods to make a call to your aspx page from JS. Here is a nice article on how to use page method with jQuery. You can return your "whatever" in your page method. If you want to serialize your server side objects before passing them to the client side, you can serialize them to JSON . Here is an example. You would just read your json data after your ajax call is successful("success: function(msg){//do something}") and update your HTML accordingly

like image 92
ram Avatar answered Nov 07 '22 23:11

ram