开发者

Prototype post data not going through to asp.net mvc Actionrequest

开发者 https://www.devze.com 2022-12-19 23:15 出处:网络
Need assistance please. (More confused than anything really) I\'ve got ASP.NET mvc controller [AcceptVerbs(HttpVerbs.Post)]

Need assistance please. (More confused than anything really)

I've got ASP.NET mvc controller

[AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Dashboard(string Whatever)
    {
        //Save name to database
        System.IO.StreamWriter swLogFile = new StreamWriter(@"c:\temp\test.txt", true);
        swLogFile.WriteLine(Convert.ToString(DateTime.Now) + ":" + Convert.ToString(DateTime.Now.Millisecond) + " - " + Whatever);
        swLogFile.Close();

        return Content("success");
    }

Simply i want to capture what is passed from (string Whatever) when data is passed via prototype on my view form.

new Ajax.Request(this.options.saveurl,
    {method:'post', Whatever:"Scott", onComplete:function(t) 
    {$('data').update(t.responseText + $('data').innerHTML);
    } });

However when this executes the 'Whatever' is always nu开发者_StackOverflowll. Am i missing something. If i use jQuery i get no problems. (my jQuery example).

jQuery.noConflict();
jQuery.post("/Home/Dashboard/Dashboardsave", { Whatever: "Scotta" }, function(data) { alert(data); });

Can anyone see what i'm doing wrong here?

Scotty


You could use the parameters property:

new Ajax.Request(this.options.saveurl, {
    method: 'post', 
    parameters: { Whatever: 'Scott' },
    onComplete: function(t) {
        $('data').update(t.responseText + $('data').innerHTML);
    } 
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号