douyinliu8813 2016-10-03 12:35 采纳率: 100%
浏览 55
已采纳

如何发送JobId并在视图上追加值。 阿贾克斯

enter image description here

This is the lotal listing fetching from the data base r_job table.. When i click view Details button it has to take the job value to controller page through ajax and there i will fetch the job information and in responsense i have to send job related table feillds and have to display on this page.

This is my Dynamic Listing:

$Jobquery = $conn->query("SELECT * FROM r_job ");
while($JobResults = $Jobquery->fetch_assoc()){

<tr>
    <td id="hiringevent"><?php echo $JobResults['hiringevent']; ?></td>
    <td id="JobId"><?php echo $JobResults['id_job']; ?></td>
    <td><button id="ViewDetails" class="btn btn-primary text-center">View Details</button></td>
</tr>

And this is my ajax and jquery Call:

$("#ViewDetails").click(function() {
    $.ajax({
            url: "job-controller.php",
            method: "POST",
            data: {'action':'viewjob','JobId' : + $('#JobId').html()},
            dataType: "json",
            success: function (response) {
                $("#showMessage").html(response['message']);
            },
            error: function (request, status, error) {
                $("#showMessage").html("OOPS! Something Went Wrong Please Try After Sometime!");
            }
        }); 
        return false;
    });

Finally my Controller Page:

if($_POST['action']=='viewjob'){ 
        $jobSearch= $conn->query("SELECT * From r_job WHERE id_job='".$_POST['JobId']."'") or die(mysql_error());
        $ViewJob=$jobSearch->fetch_assoc();
        $hiringevent        =   $ViewJob['hiringevent'];
        $jobname            =   $ViewJob['jobname'];
        $jobdescription     =   $ViewJob['jobdescription'];
        $cutoff             =   $ViewJob['cutoff'];
        $joblocation        =   $ViewJob['joblocation'];
        $interviewlocation  =   $ViewJob['interviewlocation'];
        $jobexperience      =   $ViewJob['jobexperience'];
            $response['message'] = "Show Job Information";
            $response['success'] = true;
            }else{
            $response['message'] = "OOPS! Something Went Wrong Please Try After Sometime!";
            $response['success'] = false;
        }
        echo json_encode($response);
        exit;
    }

My current issue is when i click view details only first view details button working remaining no response

  • 写回答

2条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 如何关闭soui dummy wdn 进程
      • ¥20 含有jar文件的文件夹用tar -zcvf 命令压缩后要怎么还原回去?
      • ¥15 天宝TBC软件出现报错怎么解决
      • ¥15 micropython 从1开始切片报错
      • ¥15 请问该怎么做才能将文字说明和二维码一起作为png图片一起下载
      • ¥15 r语言 混频数据回归 midas_r
      • ¥15 人脸识recogizer.predict返回值id报错,KeyError,详情如下
      • ¥15 geowebcache部署失败
      • ¥20 关于adaboost+haar特征实现人脸检测过程的一些细节问题
      • ¥15 csv文件增加一列 为csv文件的名字