Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 选择两个字段时使用ajax显示数据Liferay_Javascript_Ajax_Jquery_Liferay_Liferay 6 - Fatal编程技术网

Javascript 选择两个字段时使用ajax显示数据Liferay

Javascript 选择两个字段时使用ajax显示数据Liferay,javascript,ajax,jquery,liferay,liferay-6,Javascript,Ajax,Jquery,Liferay,Liferay 6,我正在使用ajax显示数据。当我从下拉框中选择一个名称时,我使用ajax并显示所选名称的数据。为此,我使用以下脚本: <script> $(document).ready(function(){ $('#absentEmployeeName').change(function(){ alert($(this).val()); var absentEmployeeName = ($(this).val());

我正在使用ajax显示数据。当我从下拉框中选择一个名称时,我使用ajax并显示所选名称的数据。为此,我使用以下脚本:

 <script>
    $(document).ready(function(){   
    $('#absentEmployeeName').change(function(){ 

        alert($(this).val());

        var absentEmployeeName = ($(this).val()); 
        alert("hi");

    if ($(this).val() != '') { 

    $.ajax({ 
        url : '${sendEmpNameResourceURL}', 
        data : { 

                <portlet:namespace />absentEmployeeName : $(this).val() 
        }, 
    type: 'POST', 
    dataType : "json", 
        success : function(jsonArray) { 

            alert(jsonArray);

            $('#myUniqueLabelId').html( jsonArray[0]+ jsonArray[1] + jsonArray[2]);             
        } 
        }); 
    } 
});
  });
</script>
我只传递了dropbox的id。如何传递两个字段的ID

编辑:

以下是我的HTML代码片段:

  <script>
$(document).ready(function(){   
$('#absentEmployeeName').change(function(){ 

    alert($(this).val());

    var absentEmployeeName = ($(this).val()); 
    alert("hi");

if ($(this).val() != '') { 

$.ajax({ 
    url : '${sendEmpNameResourceURL}', 
    data : { 

            <portlet:namespace />absentEmployeeName : $(this).val() 
    }, 
type: 'POST', 
dataType : "json", 
    success : function(jsonArray) { 

        alert(jsonArray);

        $('#myUniqueLabelId').html( jsonArray[0]+ jsonArray[1] + jsonArray[2]);             
    } 
    }); 
} 
});
});
</script>

<body>

 <select id="absentEmployeeName" name="absentEmployeeName" >
 <%List<Employee> EmpList = EmployeeLocalServiceUtil.getEmployees(-1,-1);
        List<LeaveCard> leaveBalList = LeaveCardLocalServiceUtil.getLeaveCards(-1,-1);
    for(Employee emp : EmpList ) {
        long empId = emp.getEmpId();
  %>
  <option value='<%=emp.getEmpId() %>' name = "leaveEmp"><%=emp.getEmpFname()%>        <%=emp.getEmpLname()%></option>

    <%}  %>
  </select>

  <div id = "empDetails">

  </div>
  <input type = "date" id = currentDate/>

 <td colspan=2>
  <input type="radio" name="forcedabsent" value="LWP">To be treated as LWP&nbsp;&nbsp;
  <input type="radio" name="forcedabsent" id = "absenteeEmp"> <label id="myUniqueLabelId"></label> to apply for leave<br><br>
 <b>Other instructions to Employee/HR</b><br>
 <textarea cols=60 rows=3 name = "markAbsentRemarks" id = "markAbsentRemarks">   </textarea>
 </td>

 </body>

你能提供你的html吗?@JSWorld:yes。。我将在问题中更新它。。给我几分钟。@JSWorld:我已经更新了这个问题。像这样==>>数据:{absentEmployeeName:$this.val,date:$currentDate.val}@Pankaj Kathiriya:好的,Prakash,那么下面的行保持不变了吗?没有变化吗?$'AbscentEmployeeName'.changefunction{
  <script>
$(document).ready(function(){   
$('#absentEmployeeName').change(function(){ 

    alert($(this).val());

    var absentEmployeeName = ($(this).val()); 
    alert("hi");

if ($(this).val() != '') { 

$.ajax({ 
    url : '${sendEmpNameResourceURL}', 
    data : { 

            <portlet:namespace />absentEmployeeName : $(this).val() 
    }, 
type: 'POST', 
dataType : "json", 
    success : function(jsonArray) { 

        alert(jsonArray);

        $('#myUniqueLabelId').html( jsonArray[0]+ jsonArray[1] + jsonArray[2]);             
    } 
    }); 
} 
});
});
</script>

<body>

 <select id="absentEmployeeName" name="absentEmployeeName" >
 <%List<Employee> EmpList = EmployeeLocalServiceUtil.getEmployees(-1,-1);
        List<LeaveCard> leaveBalList = LeaveCardLocalServiceUtil.getLeaveCards(-1,-1);
    for(Employee emp : EmpList ) {
        long empId = emp.getEmpId();
  %>
  <option value='<%=emp.getEmpId() %>' name = "leaveEmp"><%=emp.getEmpFname()%>        <%=emp.getEmpLname()%></option>

    <%}  %>
  </select>

  <div id = "empDetails">

  </div>
  <input type = "date" id = currentDate/>

 <td colspan=2>
  <input type="radio" name="forcedabsent" value="LWP">To be treated as LWP&nbsp;&nbsp;
  <input type="radio" name="forcedabsent" id = "absenteeEmp"> <label id="myUniqueLabelId"></label> to apply for leave<br><br>
 <b>Other instructions to Employee/HR</b><br>
 <textarea cols=60 rows=3 name = "markAbsentRemarks" id = "markAbsentRemarks">   </textarea>
 </td>

 </body>