我建立了一个事件来更改与ajax和json编码混合的产品名称
<div class="new-product-name"></div>
<div class="new-product-num"></div>
Run Code Online (Sandbox Code Playgroud)
然后脚本是
$(function(){
$.ajax({
method: "POST",
url: "fetch-product.php",
data: {keyword: 12}
}).done(function(msg){
$(".new-product-name").html(msg);
$.getJSON("fetch-product.php", function(data) {
$(".new-product-name").html(data.a);
$(".new-product-num").html(data.b);
});
});
});
Run Code Online (Sandbox Code Playgroud)
在fetch-product.php中
$query = "SELECT * FROM `product_details` WHERE id='". $_POST['keyword']."'";
$result = $conn->query($query);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$name=$row["p_name"];
$num=$row["num"];
}
echo json_encode(array("a" => $name, $num));
Run Code Online (Sandbox Code Playgroud)
这里的产品详细信息正在正确提取中,即使$(".new-product-name").html(msg);显示出来'{"a":"Product1", "b":"22"}',也正在进入 $.getJSON("fetch-product.php", function(data) { }
但是data.a,data.b显示出来null。
为什么data.a,data.b null?我花了太多的时间。请帮助解决此错误。
我想生成并下载网页的屏幕截图而不丢失样式。我有一个网页。在该网页中,我有一个下载按钮。当用户单击下载按钮时,整个页面的屏幕截图需要作为图像下载到用户计算机中。我怎样才能做到这一点 ?
请检查我的代码
Index.html
<html>
<body>
<link href="style.css" rel="stylesheet">
<h1>Scrrenshot</h1>
<form class="cf">
<div class="half left cf">
<input type="text" id="input-name" placeholder="Name">
<input type="email" id="input-email" placeholder="Email address">
<input type="text" id="input-subject" placeholder="Subject">
</div>
<div class="half right cf">
<textarea name="message" type="text" id="input-message" placeholder="Message"></textarea>
</div>
<input type="submit" value="Submit" id="input-submit">
</form>
<a class="btn btn-success" href="javascript:void(0);" onclick="generate();">Generate Screenshot »</a>
</body>
<script>
(function (exports) {
function urlsToAbsolute(nodeList) {
if (!nodeList.length) {
return [];
}
var attrName = 'href';
if (nodeList[0].__proto__ === HTMLImageElement.prototype
|| nodeList[0].__proto__ === HTMLScriptElement.prototype) {
attrName …Run Code Online (Sandbox Code Playgroud) 您好,我使用的是 Woocommerce 版本 3.2.6。我们有一些订单。
我想在 wordpress 后端的订单编辑页面中product id为订单添加一项额外的详细信息。123
我想添加这个:
<a href="http://example.com/new-view/?id=<?php echo $order_id?;>">Click here to view this</a>
Run Code Online (Sandbox Code Playgroud)
即:我们有order[order id =3723],订购的商品 id 是123。
然后在 中http://example.com/wp-admin/post.php?post=3723&action=edit,我想在相应的项目详细信息下方添加以下链接:
"<a href="http://example.com/new-view/?id=<?php echo $order_id?;>">Click here to view this</a>"
Run Code Online (Sandbox Code Playgroud)
我们怎样才能做到这一点?
哪个钩子适合这个。实际上我正在搜索https://docs.woocommerce.com/wc-apidocs/hook-docs.html。
我找到了 Class WC_Meta_Box_Order_Items。但我不知道如何使用这个。
嗨,我有以下内容,date = 2015-06-01 00:00:00
因此我必须在该日期前加上3个月,因此请编写以下代码
$sarting="2015-06-01 00:00:00";
$date[$i]=date('Y-m-d', strtotime($sarting . "+3 months") );
And i get the output = 2015-09-01;
Run Code Online (Sandbox Code Playgroud)
但是现在我想一次又一次地添加3个月,共20次,我必须将输出存储到数组中
所以我写下面的代码
$store_date=array();
for($i=0;$i<20;$i++){
$store_date[$i]=date('Y-m-d', strtotime($sarting . "+3 months") );
}
Run Code Online (Sandbox Code Playgroud)
但是事情正在回归2015-09-0120倍。我需要这样2015-09-01, 2015-12-01,2016-06-01。
请检查
目前我正在学习 angular4 。因此,为此我安装了 Node js ,然后在 Node js 命令提示符中执行以下命令
npm install -g typescript
npm install -g @angular/cli@1.0.0
ng new --ng4 angullar-hello-world
Run Code Online (Sandbox Code Playgroud)
通过这样做,我创建了一个有角度的项目。然后对于运行项目我输入
ng serve
Run Code Online (Sandbox Code Playgroud)
现在项目运行成功http://localhost:4200
在 nod js 命令提示符中,消息是webpack: compiled successfully. 但此后我无法在命令提示符中输入任何内容。命令提示符和项目仍然运行良好,但我无法输入任何单词或命令。我正在使用 Windows 8 和 Node v6.10.2 LTS 。
请看图片 请任何人都可以帮忙
您好,我想使用有效的 api 获取当前的金属价格值,例如黄金。我试过谷歌它没有找到一个。我可以在这里查看实时黄金价格http://goldseek.com/、https://goldprice.org/。但我没有找到 api 。因此,如果有人可以使用 php 获取当前的黄金或白银价格,那将会非常有帮助
php ×4
javascript ×2
jquery ×2
ajax ×1
angular ×1
angular-cli ×1
canvas ×1
html ×1
html5 ×1
json ×1
node.js ×1
npm ×1
orders ×1
woocommerce ×1
wordpress ×1