When writing MVC code you cannot forget jQuery. jQuery provides a substantial contribution to make your application faster.
The following is what is to be discussed:
- using $.get()
- using $.post()
- using $.ajax()
- using URL (JavaScript style)
When you are writing jQuery code, one thing to keep in your mind is that you need to minimize page loading/refreshing.
http://blogs.mooncopula.com/Home/BlogPage?blogid=4
$.get() method
$.get() method
- Calling Controller Action without parameter.
Controller:
View:- public string SaveEmployeeRecord()
- {
- string res = "this is return value";
- // do here some operation
- return res;
- }
- $.get("/Home/SaveEmployeeRecord",null, function (data) {
- alert(data);
- });
- Calling Controller Action with parameter.
Controller:
View:- public string SaveEmployeeRecord(string name)
- {
- string res = name;
- // do here some operation
- return res;
- }
- $.get("/Home/SaveEmployeeRecord", {name:'Deepak'}, function (data) {
- alert(data);
- });
- Calling Controller Action with parameter returning JSON data.
Controller:
View:- public JsonResult SaveEmployeeRecord(string id,string name)
- {
- string this_id = id;
- string this_name = name;
- // do here some operation
- return Json(new {id=this_id,name = this_name },JsonRequestBehavior.AllowGet);
- }
- $.get("/Home/SaveEmployeeRecord", {id:'67',name:'Deepak'}, function (data) {
- alert(data.id); // display id value which is returned from the action method
- alert(data.name);//display name value which is returned from the action method
- });
$.post() method
The syntax and use of the post method is just like the get method. Here instead of using the get keyword, use the post keyword and all the other things are the same.

Deepak Kumar JenaPosted Feb 28, 2020, 12:30 PM
$file ="D:\\Hello-demo.pdf" $desiredSize = 99 #for 100 kb/ minus 1 from desired kb $mockData="dump data. ignore this" $currentSize = ($mockData).length/1KB while($currentSize -lt $desiredSize) { $mockData+=$mockData $currentSize = ($mockData).length/1KB } $mockData =[string]$mockData while($currentSize -ge $desiredSize) { $mockData= $mockData.Substring(0,$mockData.Length-1) $currentSize = ($mockData).length/1KB } Set-Content $file $mockData -force
Deepak Kumar JenaPosted Feb 28, 2020, 12:15 PM
$file ="D:\\Hello-demo.pdf" $desiredSize = 99 #for 100 kb/ minus 1 from desired kb $mockData="dump data. ignore this" $currentSize = ($mockData).length/1KB while($currentSize -lt $desiredSize) { $mockData+=$mockData $currentSize = ($mockData).length/1KB } $mockData =[string]$mockData while($currentSize -ge $desiredSize) { $mockData= $mockData.Substring(0,$mockData.Length-1) $currentSize = ($mockData).length/1KB } Set-Content $file $mockData -force
Deepak Kumar JenaPosted Jul 17, 2019, 6:38 AM
.....................
Catherine OborskiPosted Jul 13, 2018, 8:21 AM
Do you have have a callback function? Can you not pass one, or pass null in its place?
NehaPosted Dec 29, 2016, 9:05 AM
Nice one..............................
NehaPosted Dec 29, 2016, 9:05 AM
Nice................................................
RakeshPosted Oct 18, 2016, 1:58 PM
Good one
kalu singh raoPosted Jul 19, 2016, 9:35 AM
Nice...
Deepak Kumar JenaPosted Jul 18, 2015, 10:25 AM
#FF0000
Sagar pandilwarPosted Feb 10, 2015, 8:55 AM
Good job..
Deepak VermaPosted Dec 16, 2014, 3:11 AM
Very good start Deepak.... nice article.
shivanagPosted Dec 16, 2014, 3:10 AM
Thanks Deepak it is very useful...
Phani BharadwajPosted Dec 16, 2014, 3:08 AM
It is useful for MVC developers...