I have a jquery file from which I'd like to call a view. The action at the controller is called Inbox. What is the right way to call this action from the jquery file?
Asked
Active
Viewed 788 times
2 Answers
2
Your question is very vague and strangely formulated, but i suppose you're looking for jquery assistance.
jQuery offers many ways to do an ajax call. The easiest one is load() $('#container').load('path/to/file.html');

pixeline
- 17,669
- 12
- 84
- 109
-
I was trying doing it this way but the code is incorrect: $.ajax({ type: "get", url: "planning/inbox", data: "s.Site="+SearchSite+"&s.Date="+SearchDate+"", }); – Hallaghan Aug 02 '10 at 16:52
-
@Hallaghan -- you should be careful of the extra trailing comma there, and add a call for success and error handling. [This question](http://stackoverflow.com/questions/377644/jquery-ajax-error-handling-show-custom-exception-messages) should get you on your way, as you can see how they've handled this. – Joshua Cody Aug 02 '10 at 17:38
0
when calling an ajax, your data must be a json object
$.ajax({
type: "get",
url: "planning/inbox",
data: { s.Site: searchSite, s.Date: SearchDate }
})

Germán Rodríguez
- 4,284
- 1
- 19
- 19
-
1Eh, not so fast. Per [the .ajax documentation](http://api.jquery.com/jQuery.ajax/), your dataType can be JSON, XML, a script, or HTML. – Joshua Cody Aug 02 '10 at 17:32
-
I called the page this way now: var SearchDate = $('#s_Date').val(); var SearchSite = $('#s_Site').val(); $('#inbox').load('planning/Inbox?s.Site=' + SearchSite + '&s.Date=' + SearchDate + ''); But it takes a long time to retrieve the view like this. – Hallaghan Aug 02 '10 at 17:35