1

I have an array ids_arr which is initialized with some values. I have to pass this array and retrieve it in an Action class.

Following is My code:

Script:

$.get('deleteProduct',
  {

    arr_ids_fm_ajax : ids_arr
  },
  function(jsonResponse){
    alert(jsonResponse.msg);
  }
    );

}

Action class:

public class ProductDetails extends ActionSupport {

    int arr_ids_fm_ajax[];

    public int[] getArr_ids_fm_ajax() {
        return arr_ids_fm_ajax;
    }

    public void setArr_ids_fm_ajax(int[] arr_ids_fm_ajax) {
        this.arr_ids_fm_ajax = arr_ids_fm_ajax;
    }

    public String deleteProduct() {
        System.out.println(arr_ids_fm_ajax[0]); // here i want the values of my
        // passed array from ajax.

        return "success";
    }
}

Error at console :

Parameter [arr_ids_fm_ajax[]] didn't match acceptedPattern pattern!

Please provide a solution. Thanks for the reply in advance.

2
  • Don't you have an extra } in the script...? Commented Jul 13, 2014 at 11:25
  • Error is clear. Your parameter name doesn't match accepted pattern. Rename it. Commented Jul 14, 2014 at 8:05

1 Answer 1

1

Passing array like this solved the problem.

data: $.param({
        arr_ids_fm_ajax: ids_arr
      }, true)
Sign up to request clarification or add additional context in comments.

1 Comment

Even during testing I'd encourage using sane, expository variable names.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.