I’m trying to construct a string param to send as a param to an AJAX call, but the various ways I’ve tried to build the string haven’t worked, including simple concatenation. Any suggestions on to do this?
var partRelationType = checkBox.name;
var partNumber = checkBox.value;
var isChecked = checkBox.checked;
$.ajax({
url: '@Url.Action("SetSelectedPart", "Select", new { customerEstimateKey = ViewBag.CustomerEstimateKey, type = partRelationType, partNumber = partNumber, isSelected = isChecked })',
type: "POST",
async: true
});
The URL is created using server side code, so you can’t use client side variables as they don’t exist yet.
Use the data property for the data instead. I’m not sure how the data is put in the URL by your server code, but something like this should work: