jquery - 如何将 PHP 转换为 jQuery
问题描述
帮我把它转换成 jQuery。它工作正常,但我想将其转换为 jQuery。我尝试了几种方法,但没有成功:(这是我的代码...................... ..................................................... ..................................................... …………………………………………………………………………
<?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");
}
}
?>
解决方案
推荐阅读
- android - 在折射期间迁移到 AndrdoidX 并不支持所有库
- android - Android 应用程序无法为 64 位共享对象创建指向本机库的软链接
- mysql - 更新查询不能在 laravel 控制器中工作
- oauth-2.0 - 使用 Google OAuth 2.0 授权的 Swagger
- laravel - 传递给 Illuminate\Auth\SessionGuard::attempt() 的参数 1 必须是数组类型、给定对象、调用
- python - 可以scrapy完全下载pdf吗
- sql - 枢轴和左连接
- android - 出于安全原因,我应该阻止我的 EditTexts 中的某些字符吗?
- css - 向右显示引导程序下拉菜单
- html - 我的 Django 网站上的图像未加载