0

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

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..

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: "http://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>

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


What i tried so far

i tried passing {%=file.name%} as below

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

Result: instead of passing value from{%=file.name%} , its passing as it is.

Expected (as it should work internally like this:)

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

Can anyone help me with this,please?

2
  • Please consider writing comment, if you down-vote. I don't know the reason of down-vote ?, is my question is not clear? Commented Nov 20, 2014 at 12:11
  • refer this link please. hope it will help you stackoverflow.com/questions/18614270/… Commented Nov 20, 2014 at 13:17

1 Answer 1

0

you should put php code betwee somthing like

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

play around with it. i have not tested it

Sign up to request clarification or add additional context in comments.

6 Comments

what is the error?. can you post updated source code?
some time php syntax error and sometime its simply passing the complete {%=file.title%} instead of value .... And please edit your question with full model path $this->tripmodel-> .... because the function which we are calling is in some other file & class . If i know just how to pass the the file name , then my problem will solve
Or can you store this ({%=file.name%}) as javascript variable ? , eg. var fn={%=file.name%}; , so that i can easily call an ajax function
i updated my question, using ajax, i am able to give alert with correct value but how can i display the value in the same place where i am giving alert?
i checked this is passing value to my model but now i have another problem, because we are mixing javascript & php its not returning value from model to display, i have asked a new question here stackoverflow.com/questions/27049395/…
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.