javascript - Post and Get value by jquery ajax -


how can add values owdid , visited id after clicking below link ajax?

<a href="index.php" onclick="insertvisit(<?php echo $interestid;?>)">member1</a> 

below insertvisit function. have defined owdid , interestid

function insertvisit(visitedid) {   $.ajax({        type: "post",        url: 'insertvisit.php',        data:{'field1' : owdid, 'field2' : visitedid},        success:function(html) {        }   }); } 

and below insertvisit.php

global $pdo; $ownid = $_get['field1']; $interestid =$_get['field2'];  $query = $pdo->prepare("update tablem set field1= ? field2= ?"); $query -> bindvalue(1, $ownid); $query -> bindvalue(2, $interestid); $query -> execute(); 

please thanks.

you need pass both value in function , separated , need change function call bellow

<a href="index.php" onclick="insertvisit(<?php echo $interestid.','.$owdid;?>)">member1</a> 

and function :

function insertvisit(visitedid,owdid) {    $.ajax({            type: "post",            url: 'insertvisit.php',            data:{'field1' : owdid, 'field2' : visitedid},            success:function(html) {            }    }); } 

and need change method $_get $_post below

$ownid = $_post['field1']; $interestid =$_post['field2'];  $query = $pdo->prepare("update tablem set field1= ? field2= ?"); $query -> bindvalue(1, $ownid); $query -> bindvalue(2, $interestid); $query -> execute(); 

i hope you.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -