javascript - 如何使用 JavaScript 在 URL 中传递值?

标签 javascript real-time

我正在尝试做一个实时投标系统来投标工作。我做了实时代码,我可以在表格中查看工作。在每一行中都有一个链接,当我单击它时,它应该将我带到另一个页面,其中 url 中包含 id 值。我的问题是,当我单击“应用”链接时,它没有将我带到第二页。 有人可以帮我吗?

 $(document).ready(function(){
done();
   });

 function done(){
 setTimeout(function(){
updates();
 done();

},500   );
 }

 function updates(){

   $.getJSON("jobs_by_company_PHP.php", function(data){

$(".text_2").empty();
$("#subbu").empty();

$.each(data.result,function(){ 

     $(".text_2").append("<style>table, td, th {    border: 1px solid #ddd;
   text-align: left; width:400px;  font-size: 30px;}"+
               "     table {"+
            "  border-collapse: collapse;"+
            "  width: 170%; "+
             "   font-size: 30px;  "+
             "margin-left:0px;"+
         " } "+

        "  th, td {"+
        "width:400px;"+
         "     padding: 15px;  "+
          "      font-size: 30px;   "+
         " }      "+



     "</style> <table  summary='Summary Here' cellpadding='0' cellspacing='0'>" +
     "<thead>" +
        "<th>  ID </th>"  +
        "<th>Name</th>"  +
         "<th>end_date</th>"  +
          "<th> time</th>"  +
           "<th> apply</th>"  +
    "  </tr>  "+
  "  </thead>"+

    " <tbody>  "    +
      '<tr class="light">' +

    "<td>"+this['id']  +" </td>" +

    "<td> "+this['name']+" </td>" +
      "<td> "+this['end_date']+" </td>" +
       "<td> "+this['time']+"</td>" +

     "<td><a onclick="+ 'location.href="../index.php?id="'+this['id']+'";"'+
       "a>Apply</a></td> "+


     "</tr>"+

  "  </tbody>        "+

    "</tr> "+
    " </tbody>"+
    "</table>");
});

});
}

最佳答案

id="'+this['id']+'";" 给出 id="whateverid" 删除你的 id 周围的引号,例如 id='+this['id']+';"

关于javascript - 如何使用 JavaScript 在 URL 中传递值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36185514/

相关文章:

javascript - Knockout.js - 如何修改可观察的 JS Date 对象?

javascript - 使用javascript在iframe中打开本地pdf文件

javascript - 无法更新 React Js 中的状态

garbage-collection - Lua 的 GC 和实时游戏

android - Android静态方法可以实时很好地绘制后台线程数据,但这是一个好的解决方案吗?

javascript - 当 isUpload 为真时,Ext.Ajax.request 回调从不调用

javascript - Highcharts - 在打印页面中隐藏导出菜单

javascript - Angular q.all 即时响应与延迟响应

c++ - 在用户输入时捕获输入流

c - sleep 时信号处理比旋转时慢?