Add input values to ajax data

Add input values to ajax data

qreftanqreftan Posts: 4Questions: 1Answers: 0

This does not work: (partial code)

"ajax": {
"data": {
"SearchViewModel.Inspection": $('#SearchViewModel_Inspection')
},
}

This works: (partial code)

"ajax": {
"data": {
"SearchViewModel.Inspection": 'test'
},
}

How can I push my input value to the form?

Answers

  • qreftanqreftan Posts: 4Questions: 1Answers: 0

    Typo: $('#SearchViewModel_Inspection').val()

  • qreftanqreftan Posts: 4Questions: 1Answers: 0

    It submits the value, but when i type in a new value in the input the old value is still there. I somehow need to refresh the ajax data attribute

  • qreftanqreftan Posts: 4Questions: 1Answers: 0

    Solved it.

                "data": function (d) {
                    return $.extend({}, d, {
                        "SearchViewModel.Inspection": $('#SearchViewModel_Inspection').val(),
                        "SearchViewModel.OwnerName": $('#SearchViewModel_OwnerName').val(),
                        "SearchViewModel.BoatClub": $('#SearchViewModel_BoatClub').val(),
                        "SearchViewModel.Registered": $('#SearchViewModel_Registered').val(),
                        "SearchViewModel.Locked": $('#SearchViewModel_Locked').val(),
                        "SearchViewModel.Approved": $('#SearchViewModel_Approved').val(),
                        "SearchViewModel.DateStart": $('#SearchViewModel_DateStart').val(),
                        "SearchViewModel.DateEnd": $('#SearchViewModel_DateEnd').val(),
                        "SearchViewModel.MyInspections": $('#SearchViewModel_MyInspections').val()
                    });
                },
    
This discussion has been closed.