Reputation: 941
I am calling a AJAX refresh of a MVC4, and I debug in google chrome.
The text is below. the ogid is a number (as text).
The script below works - up to a point. It generates the following url
http://localhost:54534/AddInschrijvingen/ListKandidaten?id%5B%5D=9
<script>
$("#OpdrachtgeversID").change(function () {
var ogid = $("#OpdrachtgeversID").val();
$.ajax({
url: 'AddInschrijvingen/ListKandidaten',
type: 'GET',
data: { id: ogid },
succes: function(data) {
$('#StatesDivID').html(data)
}
})
})
</script>
if I replace the data: { id: ogid} by { id: 7} it generates the following:
http://localhost:54534/AddInschrijvingen/ListKandidaten?id=7
The last is what I need, but I still need it formed with a variable. What am I missing?
Upvotes: 0
Views: 86
Reputation: 63075
try by parseInt
var ogid = parseInt($("#OpdrachtgeversID").val(), 10);
%5B%5D
means []
, may be your ogid
may not have correct number as you expected.
Upvotes: 1