使用ajax获取值

使用ajax获取值

问题描述:

here is my link

<a data-toggle="tooltip" data-placement="top" title="Edit" class="btn btn-info" href="close_case_edit.php?pw_case_close_id= <?php $row['pw_case_close_id']; ?>">

On next page I fetch value using php

$pw_case_close_id = $_GET['pw_case_close_id'];

but i want fetch this value using ajax as i want update this page using API

这里是我的链接 p>

 &lt; a data-toggle  =“tooltip”data-placement =“top”title =“编辑”class =“btn btn-info”href =“close_case_edit.php?pw_case_close_id =&lt;?php $ row ['pw_case_close_id'];?&gt;”&gt  ; 
  code>  pre> 
 
 

在下一页我使用php获取值 p>

  $ pw_case_close_id = $ _GET ['pw_case_close_id']  ; 
  code>  pre> 
 
 

但我希望使用ajax获取此值,因为我想使用 API更新此页 p> div>

You can use .split() along with .attr()

A sample working example:-

$(document).ready(function(){
 var value = $('a.btn-info').attr('href').split('=')[1];
 console.log(value);

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a data-toggle="tooltip" data-placement="top" title="Edit" class="btn btn-info" href="close_case_edit.php?pw_case_close_id=2">

</div>