我在shopify工作,我是新手我在公共应用的iframe中添加了表单,请参阅https://snag.gy/P3QpXl.jpg
我想要的是我想在我的数据库中存储该值如何使用表单参数向我的服务器发送请求所以我可以将所有表单数据保存在我的数据库中 这是我的表单代码
<form>
<div class="row">
<div class="large-4 columns">
<div class="row collapse">
<label>Title</label>
<div class="small-12 columns">
<input type="text" placeholder="Product Name" name="title" />
</div>
<label>Description</label>
<div class="small-12 columns">
<input type="text" placeholder="Product Description" name="body_html" />
</div>
<label>Image Url</label>
<div class="small-12 columns">
<input type="text" placeholder="Image Url" name="image_src" />
</div>
</div>
</div>
</div>
<div class="row">
<div class="large-4 columns">
<button class="button product_submit">Submit</button>
</div>
</div>
以下是脚本我不确定是否有其他shopify方式将数据发送到我的服务器
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js">
<script src="https://cdn.shopify.com/s/assets/external/app.js"></script>
<script type="text/javascript">
ShopifyApp.init({
apiKey: "api_key",
shopOrigin: 'domin'
});
</script>
<script src="assets/js/custom.js"></script>
<script>
$('.product_submit').on('click', function(e){
e.preventDefault();
$.ajax({
url: '/products',
type: 'POST',
data: $('form').serialize(),
success: function(data){
// ShopifyApp.flashNotice("Product Uploaded Successfully");
$('form')[0].reset();
},
error: function() {
//ShopifyApp.flashError("Warning: Product Uploaded Failed");
}
})
});
</script>
当我点击使用以下代码创建的https://snag.gy/luEKcP.jpg 保存按钮时,我希望这可以保存数据
ShopifyApp.flashError("Warning: Product Uploaded Failed");
ShopifyApp.Bar.initialize({
title: 'Dashboard',
icon: 'upsell-hero/assets/images/logo.png',
buttons: {
primary: {
label: "Save",
message: 'bar_save'
},
});