How to Convert PHP to jQuery

Help me guys to convert this into jQuery. It works fine but I want to convert this in to jQuery. I tried several ways but it didn't work :( Here is my code.....................................................................................................................................................

<?php
$f_pId = $_GET['f_pId'];
$f_pName = $_GET['f_pName'];
$f_pStock = $_GET['f_pStock'];
$f_pPrice = $_GET['f_pPrice'];

echo "$f_pId, $f_pName, $f_pStock, $f_pPrice";

$xml = new DomDocument('1.0','UTF-8');
$xml->formatOutput = true;
$xml->preserveWhiteSpace = true;
$xml->Load('products.xml');

$allProducts = $xml->getElementsByTagName('product');
$exist= 0;

foreach ($allProducts as $eachtProduct) {
$pId = $eachProduct->getElementsByTagName('pId');
if($f_pId == $pId->item(0)->nodeValue){
    $exist= 1;
    break;
}
}

if($exist== 1){
echo "<br />Product Already exists.";
header("refresh:3,url=simpleDomWithPhp3L.php");
}else{

$nProduct = $xml->createElement('product');

$npId = $xml->createElement('pId',$f_pId);
$npName = $xml->createElement('pName',$f_pName);
$npStock = $xml->createElement('pStock',$f_pStock);
$npPrice = $xml->createElement('pPrice',$f_pPrice);

$nProduct->appendChild($npId);
$nProduct->appendChild($npName);
$nProduct->appendChild($npStock);
$nProduct->appendChild($npPrice);

$productList = $xml->getElementsByTagName('productList');

$productList->item(0)->appendChild($nProduct);

if($xml->save('products.xml')){
    echo "<br />Product Added.";
    header("refresh:3,url=simpleDomWithPhp3L.php");
}else{
    echo "<br />errer";
    header("refresh:3,url=simpleDomWithPhp3L.php");
}
}
?>