-1

I am loading a modal in a page that the user can then interact with.

var global_id=$(this).data('global-id');
var other_global_id=$(this).data('other-global-id');
var comment=$('#pairing-comment').val();  // <- this is not working!!!

but I'm not sure how to access this properly. I've tried scoping it but maybe this can't be done although I think it can me. Here it is console:

enter image description here

so this is happening in response to a user event so it's definitely happening later.

$(document).on('click','#comment-submit', function(){
    arc_eh.event_handler.submit_pairing_comment.call(this);
  });
4

2 に答える 2

1

これはスコープとは関係ありません。変数を割り当てようとすると、$('#pairing-comment')要素にはまだ値がないという事実と関係があります。

AJAX 呼び出しの成功関数に変数を割り当てて、値の準備ができていることを確認する必要があります。

于 2013-08-15T20:34:53.800 に答える