October 21, 2024
Chicago 12, Melborne City, USA
jQuery

jQuery.ajax showed value as nothing (null) when debugging shows a value


In an MVC 5 app I have this bit of script

  vWidth = $(window).width();
 alert("1278 - Window Width - " + vWidth);
$('#HiddenField').val('1');
debugger;
  jQuery.ajax({
      url: '@Url.Action("ManageCreditCards", "Manage")',
      type: 'POST',
      data: {WindowWidth: vWidth},
      success: function (response) {
          $('#ManageCC_Div').html(response);
      },
      error: function (xhr, ajaxOptions, thrownError) {
          ModalError(xhr.responseText + " - " + thrownError);
      }
  })

The value passing through to the controller is always nothing (null).

An alert is showing a value.

Setting debugger; in the code and stepping through it shows it has a value.

What on earth can I be missing here?

Debugger



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video