Firefox与Safari的JavaScript

时间:2015-10-02 18:36:15

标签: javascript jquery firefox safari

在Firefox中,这段代码就像魅力......但在Safari中,它不会执行......我哪里出错了?

$('#ul_stages li.stage').on('click', updateStageByClick);

function updateStageByClick() {
   var id = $(this).parent().attr('class').substr(6);
   var pid = $('form#data input[name=pid]').val();
   var stage = $(this).val();
   $.ajax({
     type: "POST",
     url: "/invite/stage",
     data: {project: pid, user: id, stage: stage},
     dataType: 'json',
     success: update
   });
   return false;
}

<ul id="ul_stages" class="stage_<?= $profile['user_id'] ?>">
   <li>SELECT STAGE:</li>
   <li class="stage_unviewed stage" value="0">Unviewed</li>
   <li class="stage_viewed stage" value="1">Viewed</li>
</ul>

1 个答案:

答案 0 :(得分:0)

尝试使用:

$('form#data input[name="pid"]').val();