1

I have an ajax call like so:

    $.ajax({
        type: "GET",
        url: "/api/connection/NotifiyNextDepartment?questionId=" 
             + highestValue + "&department=" + jobTitle + "&customerId=" + customerID + "&jobNumber=" 
             + $("#communtiyDropdown").val() + $("#lotDropdown").val(),
        dataType: "json",
        cache: false,
        success: function (data) {}
    });

    alert('Success, you\'re data has been saved!');

    holder = [];
},
failure: function (errMsg) {
    alert('Failed, somthing went wrong, please try again!');
}

jobTitle is equal to "Human Resources & Customer Experience Manager"

when I send it to .NET I only get this back:

public bool NotifiyNextDepartment(int questionid, string department, int customerId, string jobNumber)
{
}

Here department is equal to "Human Resources "

Why is .NET removing everything after the & and how do I fix this?

Szabolcs Dézsi
  • 8,743
  • 21
  • 29
user979331
  • 11,039
  • 73
  • 223
  • 418

1 Answers1

1

I think you should call encodeURIComponent on your parameters.

url: "/api/connection/NotifiyNextDepartment?questionId=" 
         + encodeURIComponent(highestValue) + "&department=" + encodeURIComponent(jobTitle) + "&customerId=" + encodeURIComponent(customerID) + "&jobNumber=" 
         + encodeURIComponent($("#communtiyDropdown").val() + $("#lotDropdown").val()),
Szabolcs Dézsi
  • 8,743
  • 21
  • 29