2

I have a simple javascript code, that validate when you write a order number and generates tags with javascript(with bootstrap-tagsinput js):

 var order = $('#order_number').val();

 if ($.inArray(order, $('#input_order_tags').val()) >= 0) {
  $('#input_order_tags').tagsinput('add', order);
  return;
 }

 var params = {
  email: email,
  order_code: order
 }

 AjaxServices.validateOrderNumberByEmail(params, function(error, result) {
  if (error)
   alert(error);
  else
   $('#input_order_tags').tagsinput('add', result.order);
 });

This works fine but, every time trigger the error message when send a order number: enter image description here

enter image description here

Console chrome debug: enter image description here

How I can avoid the error of alert?

2 Answers 2

0

This is not a javascript issue. Server-side in you application you use order_code in one of the calls which returns the error message you see in the ajax call. Debug the offending call server-side, see which call returns that error and adjust your code so it works properly.

Sign up to request clarification or add additional context in comments.

Comments

0

There might be two possibilities

  1. client side issue ( javascript error) if so, its because the field order_number is disabled field. as mentioned in this link undefined index on javascript dynamic variables when passing to php form If so, remove that disabled and use read-only and check if it works, without any error.

  2. Server side issue( ajax call) if so, server side code which performs on call of that ajax call is causing that issue.

Comments

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.