2

When I am going to submit data using AJAX that time IE display error like object doesn't support this property or method

  $("#savebasicInfo").live("click",function()
  {

    var lookingfor='';
    var interestedIn='';
    $(".lookingfor").each(function(i)
    {
      if(this.checked == true)
      {
        lookingfor= lookingfor+","+$(this).val().trim();  // error found here
      }
      i++;
    });
    $(".interestedIn").each(function(j)
    {
      if(this.checked == true)
      {
        interestedIn= interestedIn+","+$(this).val().trim(); // error found here
      }
      j++;
    });
    $.ajax(
    {

      type: "POST",
      url: $("#cfgRoot").val()+'/accounts/basicInfoPost.php',
      data:
      {
        city:$("#city").val().trim(),
        hometown:$("#hometown").val().trim(),
        interestedIn:interestedIn,
        relationship:$("#relationship").val().trim(),
        lookingfor:lookingfor,
        political:$("#political").val().trim(),
        religious:$("#religious").val().trim()
      },
      success: function(responce)
      {
        if(responce == 1)
        {
            $("#basicProfileMain").load("basicInfoMain.php");
            $("#basicProfileMain").css({"height":"auto"});

        }
      }
    });
  });
Sumit Bijvani
  • 8,154
  • 17
  • 50
  • 82
  • 1
    IE doesn't support trim see this question http://stackoverflow.com/questions/2308134/trim-in-javascript-not-working-in-ie – Damon Skelhorn Feb 12 '13 at 06:56

1 Answers1

4

You cannot 'trim' a string as such in JavaScript as there is no trim method in core js. However, you can use jQuery's trim function.

$.trim($(this).val())
darshanags
  • 2,519
  • 1
  • 13
  • 19