Click here to Skip to main content
15,868,419 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
am developing a MVC application .net.

I have a textbox called "Products". I have to autopoulate the textbox with the list from the server using jquery and ajax

Here is the code:
@Html.TextBoxFor(model=>model.Products,new {@id = "Products"})
In this textbox ,I need to call an action of a controller by ajax and get the data.
$('#Products).autocomplete()
{
alert('kl');
AutoCompleteDetails()
}

function AutoCompleteDetails()
{
var url = '@Url.Action("Search", "Student")';
href = url;

$.ajax({
url: href,
dataType: "json",
data: AutoDetails,
type: "POST",
context: this,
success: function (data) {

}
On the page load, the control is hitting Search action of Student controller, I have two doubts here:
1.
On page load, after hitting "Search" action I am binding the model values back to the page but these values are not seen as dropdown as suggestions in the textbox called "Products"

2.
After the page load, when I type "KL" and tab out the action "Search" of "Student" controller is not getting called.


Any suggestions?
Posted

1 solution

I think somewhere your javascript code fails to successfully call controller method.Try to debug it using FireBug.Put breakpoint in your Ajax call.Inspect whether or not it is executed fully and see console window if it is making a request to server successfully.If not try to rectify your Ajax call wherever it breaks.I think there is a problem in your "data: AutoDetails".Please check it properly.After debugging run the project again.Hopefully this will help you in resolving your problem.Thanx...
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900