如何从java脚本模板传递php参数

编程入门 行业动态 更新时间:2024-10-27 18:20:14
本文介绍了如何从java脚本模板传递php参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在下面有一个代码,通过从上传图片的文件夹中读取图片名称来显示图片名称。

I have a code below, which display image name on UI by reading it from the folder where those images are uploaded,

这些图片名称使用 java脚本模板,我想将该名称传递给php函数,以检查其状态

These image names are displaying using a java-script template, I want to pass that name to a php function in order to check its status by hitting the db by the image name..

以下是图片名称在UI中的显示方式:

Here is how the image name is displaying in UI:

<!-- The template to display files available for download --> <script id="template-download" type="text/x-tmpl"> {% for (var i=0, file; file=o.files[i]; i++) { %} <tr class="template-download fade"> <td> <span>{%=file.name%}</span> <!----- new update --------> var a= file.name; $.ajax({ type: "POST", url: "localhost/tripvioapp/trips/showStatus/", dataType: "text", data: {image_name: a,trip_id: '2'}, success: function(msg){ alert(msg);//how can i display this value in this place } }); </td> </tr> {% } %} </script>

基本上,我已经集成了使用Codeigniter进行文件上传(php框架)从本教程

Basically, i have integrated file upload with Codeigniter(php framework) From this tutorial

到目前为止我尝试了

{%= file.name%} 如下

$this->tripmodel->getImageStatusByUidName('\"{%=file.title%}\"',"2"); //calling php function

结果:

预期(因为它应该工作)

$this->tripmodel->getImageStatusByUidName("imageName.jpg","2");

任何人都可以帮我解决这个问题吗?

Can anyone help me with this,please?

推荐答案

你应该把php代码放在之类的

you should put php code betwee somthing like

<?php $this->tripmodel->getImageStatusByUidName( "{%=file.name%}","2"); ?>

使用它。我没有测试它

更多推荐

如何从java脚本模板传递php参数

本文发布于:2023-07-07 04:43:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1058916.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   模板   参数   java   php

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!