你如何在浏览器中调用这个ajax函数 [英] How do you call this ajax function in the browser

查看:107
本文介绍了你如何在浏览器中调用这个ajax函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个带有Home控制器的mvc项目,其方法为

  public  ActionResult Index()
{
return View();
}





返回视图Index.cshtml。



在Index.cshtml中,我有这个ajax请求:



 $ .post('  superman',{field1:   hello,field2:  hello2 },
function (returnedData){
console 。 log(returnedData);
});









如何调用此ajax请求在浏览器中?



我尝试了什么:



i尝试< a href =http:// localhost:58455 / home / superman.html> [ ^ ]

解决方案

.post(' superman',{field1: hello,field2: hello2},
function (returnedData){
console .log(returnedData);
});









如何调用此ajax请求在浏览器中?



我尝试了什么:



i尝试< a href =http:// localhost:58455 / home / superman.html> [ ^ ]


如果代码中没有错误,则可以使用事件发送请求。您可以将它附加到事件处理程序,然后在该块中编写此代码以执行它。例如,

 


'

i have created a mvc project with a Home controller with a method

public ActionResult Index()
        {
            return View();
        }



that returns the view Index.cshtml.

In Index.cshtml , i have this ajax request:

 $.post('superman', { field1: "hello", field2: "hello2" },
function (returnedData) {
    console.log(returnedData);
});





How would i call this ajax request in the browser ?

What I have tried:

i tried [^]

解决方案

.post('superman', { field1: "hello", field2: "hello2" }, function (returnedData) { console.log(returnedData); });





How would i call this ajax request in the browser ?

What I have tried:

i tried [^]


If there are no errors in the code then you can use events to send requests. You can attach it to an event handler, then write this code in that block, to execute it. Such as,


('


这篇关于你如何在浏览器中调用这个ajax函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆