将身体的请求发布到模型中

时间:2016-04-10 08:49:45

标签: post model

我必须使用javascript实现它。

我有这堂课:

Public Class RecommendedJobsData
    Public Property searchedJobsList As List(Of JobInfo)
    Public Property jobFromStorage As JobInfo
    Public Property totalJobsCount As Integer
    Public Property adType As AdType

    Public Sub New() ' default constructor

    End Sub

    ' constructor with parameters
    Public Sub New(searchedJobsList As List(Of JobInfo), jobFromStorage As JobInfo, totalJobsCount As Integer, adType As AdType)
        Me.searchedJobsList = searchedJobsList
        Me.jobFromStorage = jobFromStorage
        Me.totalJobsCount = totalJobsCount
        Me.adType = adType
    End Sub
End Class

我正在尝试向此功能发送帖子请求:

<JsonpFilter()>
Public Function GetToken(header As RequestHeader, body As RecommendedJobsData) As String

    Return String.Empty

End Function

所以我使用了javascript:

var http = new XMLHttpRequest();

http.open("POST", url, true);

//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

http.onreadystatechange = function () {//Call a function when the state changes.
    if (http.readyState == 4 && http.status == 200) {
        alert(http.responseText);
    }
}
http.send(apiParams);

标题传递正常,但正文不是..

它进入默认构造函数而不是获取参数的构造函数,然后,GetToken函数的主体对象中存在空值。

这是apiParams:

enter image description here

任何帮助表示赞赏!

0 个答案:

没有答案