javascript - jQuery - changing page with sending a POST parameter -


scenario is:

i have html a-tag in page(call 'index.php') link page (lets call page 'action.php') !

'action.php' page needs receive post parameter, otherwise return error!

i have needed parameter in 'index.php' page, dont want use form-tag send it. whenever user clicked on a-tag, parameter should sent 'action.php' page.

indeed, ajax has nothing here, while want change page, sending post parameter whenever user click on < > !

example: index.php

<a class='showproject' href='action.php' data-pid='<?php echo project_id ?>'> project </a> 

action.php

 echo $_post['project_id'];   

i prefer that, if there way this, jquery code starts following event:

$('.showproject').on('click',this,function(e){       /* solution */ }); 

you can use ajax this. don't know have parameter want pass action.php, in example it's stored in hidden value.

$('.showproject').click(function() {   var productid = $("#hiddenfield").value();     $.ajax({       type: 'post',       url: 'action.php',       data: {productid: productid},       success: function(data) {                //do whatever need return data.           },       error: function(xhr, ajaxoptions, thrownerror) { }      }); }); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -