JavaScript Model-AJAX- MVC Model

var data = {};
data.columnname = $InputElement.attr('data-columnname');
data.datatype = $InputElement.attr('data-datatype');
data.value = $InputElement.val();


$.ajax({
    type: 'POST',
    url: 'http://localhost:50929/Conversation/SubmitAnswer/', //last '/' is important

    contentType: 'application/json; charset=utf-8',
    data: JSON.stringify({ data: data }),
    dataType: 'json',
    beforeSend: function () {

    },
    success: function (response) {

    },
    error: function (request, status, error) {
    },
    complete: function () {
    }
});

public class Answer
{
    public string columnname { get; set; }
    public string datatype { get; set; }
    public string value { get; set; }
}


[HttpPost]
public JsonResult SubmitAnswer(Answer data)
{

}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s