Hello-World
Hello-World

Reputation: 9545

jquery ajax post to .aspx page load - how to read variable posted?

I am trying to do a ajax post to a aspx page . How do I read the variable "myVar"? in the code below HttpContext.Current.Request("myVar") brings back nothing

var p = { "myVar": JSON.stringify(tableOBJ) };

$.ajax({
    type: "POST",
    url: "Default2AJAX.aspx",
    data: p,
    success: function (data) {

    }
});

Default2AJAX.aspx code behind

Partial Class Default2AJAX
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim s As String = HttpContext.Current.Request("myVar") ''not working???????

    End Sub

End Class

Upvotes: 0

Views: 2635

Answers (1)

Musa
Musa

Reputation: 97672

I think it should be

HttpContext.Current.Request.Form("myVar")

Upvotes: 2

Related Questions