php - How to get values passed via GET with ajax -


say have following, , got ids dynamically.

<div class="search_results"> <p>user 1 <a href="phpfile.php?id=3">add</a></p> <p>user 1 <a href="phpfile.php?id=4">add</a></p> </div> 

if didn't use ajax, catch passed values in phpfile.php $_get['id'], how can use jquery?

$.ajax({     type: 'get',     url: 'phpfile.php', // how add values here?     success: function(data) {         // smth     } }); 

you need add data parameter:

url: 'phpfile.php', data: {id: 3} 

if have take id html displayed:

$('.search_results a').click(function (e) {   e.preventdefault();   $.ajax({     type: 'get',     url: 'phpfile.php',     data: {id: $(this).attr('href').match(/id=(\d*)/)[1]},     success: function (data) {         //     }   }); }); 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

java - More than one row with the given identifier was found: 1, for class: com.model.Diagnosis -