如何在MVC中使用AJAX [英] How to use AJAX with MVC
本文介绍了如何在MVC中使用AJAX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨..我想在MVC中使用AJAX。任何链接或任何形式的帮助将受到高度赞赏。
假设我有一个文本框,我必须输入一些名字。当我在其上输入任何字符时,它应该从我的数据库中带来与我输入的字符类似的所有名称。
解决方案
下面是一个使用ajax的简单示例在一个mvc项目中
函数BindDropdown(){
< blockquote> .ajax({
url:/ apiFolder / ApiName,
类型:获取,
dataType:'json',
成功:函数(数据,状态) ,xhr){
var vItems =< 选项 value =' 0' > ..选择.. < / option > ;
(#ddlRDName)。空();
Hi.. I want to use AJAX with MVC. Any links or any sort of help would be highly appreciated.
Let's say I have a text-box where I have to enter some name. When I enter any character on it then it should bring all the names similar to the character I entered, from my database.
解决方案
below is a simple example to use ajax in a mvc project
function BindDropdown() {
.ajax({ url: "/apiFolder/ApiName", type: "Get", dataType: 'json', success: function (datas, status, xhr) { var vItems = "<option value='0'> ..Select.. </option>";
("#ddlRDName").empty();
这篇关于如何在MVC中使用AJAX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文