I think you may be looking for something like this...
var dataString = res[1];
console.log( 'pid=' + dataString );
$.ajax({
type: "POST",
url: 'Task2.php',
data: { pid: dataString },
success: function(data) {
alert(data);
}
});
by specifying data: { pid:dataString } in your ajax call, your telling it to POST the dataString value as a form element named "pid". You chould be able to pick it up PHP side with $_POST['pid'];
EDIT
Here is a full, working example. All self contained in a single PHP file. Should help you get it sorted out. The reason for the isset($_GET['testing']) at the top is because I'm using the same file in the ajax call too. Just fyi...
<?php
if (isset($_GET['testing'])) {
if (isset($_POST['pid'])) {
echo $_POST['pid'];
} else {
echo 'not set';
}
}
else
{
?>
<html>
<script src="http://code.jquery.com/jquery-1.12.0.min.js"></script>
<a href="javascript:void(0);" onclick="test()">test</a>
<script type="text/javascript">
function test() {
var dataString = "pid=testing123";
$.ajax({
type: "POST",
url: "test.php?testing",
data: dataString,
success: function(result) {
alert(result);
}
});
}
</script>
</html>
<?php
}
?>