views:

63

answers:

2

Does $.get() work if I'm working with ASP.NET MVC?

If so, would someone please give me an example? I have written an aspx page that I wish to call using $.get(), in which I intend to call some function and send a response back to the page.

If not, then would someone please point out an alternative?

+1  A: 

Uh, do you mean jQuery? If so, yes, it works (and ships) with ASP.NET MVC. If not, please describe your question a bit more.

JoshJordan
i am using a mvc page i want to call an aspx page using $.get and perform some function there in that page . and get back a response
lucky
I guess you need to post a code example. I don't know what it means to "call an aspx page."
JoshJordan
i created a new aspx page , an then i want to do is call this aspx page via a on click event . but when that event fires the $.get doesn't call the page .The code i wrote is function hi(){ $.post("help.aspx", {}, function(r) { alert(r); });}
lucky
A: 

What are you trying to do? If you are trying to return data back to load a div tag (for example), use $('#divid').load

If you want to save a value to the database using Ajax, this works perfect:

    $.ajax({
        url: "Services/FreebieWebService.asmx/Click",
        type: "POST",
        data: ({ id: freebieId }),
        success: function() {
            voteCountItem.html((voteCountItem.html() * 1) + 1);
        }
    });

And yes, this is code straight from my MVC website.

Martin