Hello i am not familiar with returning HTML in Javascript code. I have this code. I want to return an audio player but nothing returns.

var uploadImageHTMLTitle='<audio controls preload="metadata" id="'+data.msg_id+'">';
                    var uploadImageHTMLFooter='</audio>';
                    var uploadImageHTML='';
                    var C='';
                    if(data.uploadPaths.length)
                    {
                        if(data.uploadPaths.length > 1)  
                        {
                            uploadImageHTML+=uploadImageHTMLTitle;
                            for(var i=0; i<data.uploadPaths.length; i++)
                            {
                                C='<source src="'+data.uploadPaths[i]+'" type="audio/mp3" /><source src="'+data.uploadPaths[i]+'" type="audio/mp4" /><source src="'+data.uploadPaths[i]+'" type="audio/wav" /><source src="'+data.uploadPaths[i]+'" type="audio/ogg" />';

                                uploadImageHTML += C;
                            }
                            uploadImageHTML+=uploadImageHTMLFooter;
                            sliderLoad(data.msg_id);
                        }
                        else
                        {
                            uploadImageHTML='<source src="'+data.uploadPaths[0]+'" type="audio/mp3" /><source src="'+data.uploadPaths[0]+'" type="audio/mp4" /><source src="'+data.uploadPaths[0]+'" type="audio/wav" /><source src="'+data.uploadPaths[0]+'" type="audio/ogg" />';
                        }
                    }

Recommended Answers

All 3 Replies

This a complete function so we can't see what should be being returned or when.
I can't see an error in what you are doing here but what happens to the HTML after that?

This is what follows.

var html='<div class="newsFeed-block timeline-block item newsFeed'+data.msg_id+data.created+'" id="newsFeed'+data.msg_id+'"  rel="'+data.created+'" >'+
                '<div class="panel panel-default">'+
                '<div class="panel-heading">'+
                '<div class="media">'+
                    '<a href="'+baseUrl+data.username+'" class="pull-left">'+
                        '<img src="'+data.profile_pic+'" class="media-object smallFace">'+
                    '</a>'+
                    '<div class="media-body">'+
                        '<a class="feedDelete commonDelete" c="'+data.created+'" href="#" id="deleteFeed'+data.msg_id+'" rel="" title="Delete Media"></a>'+ 
                        '<a href="'+baseUrl+data.username+'" class="feed-author">'+data.name+'</a>'+
                        '<a href="'+baseUrl+'status/'+data.msg_id+'" class="timeago" title="'+data.timeAgo+'"></a>'+
                    '</div>'+
                '</div>'+
          '</div>'+
          '<div class="panel-body">'+
            '<p class="feedContent">'+data.message+'</p>'+
          '</div><div>'+embed+'</div>'+uploadImageHTML+geoHTML+
            '<div id="likeUserDiv'+data.msg_id+'" class="likeUserDiv'+data.msg_id+data.created+'">'+
            '</div>'+
            '<div class="st_like_share">'+
                '<a href="#" class="reaction like  icontext like'+data.msg_id+data.created+'" c="'+data.created+'" id="like'+data.msg_id+'" title="Like" rel="Like" data="0"><i class="fa fa-heart"></i>'+Like+'</a>'+
                '<a href="#" class="commentopen  icontext " id="commentopen'+data.msg_id+'" rel="'+data.msg_id+'" c="'+data.created+'" title="Review"><i class="fa-review"></i>'+Comment+' </a>'+
          shareHTML+
            '</div>'+   
            '<ul class="comments comments'+data.msg_id+data.created+'" id="comments'+data.msg_id+'">'+
          '</ul>'+
          '<ul class="comments displaynone commentBox commentBox'+data.msg_id+data.created+'" id="commentBox'+data.msg_id+'">'+
            '<li class="comment-form " >'+
          '<div class="input-group">'+
            '<input type="text" class="form-control placeComment commentText'+data.msg_id+data.created+'" placeholder="'+placeComment+'" id="commentText'+data.msg_id+'"/>'+
            '<span class="input-group-addon">'+
            '<a href="#" id="commentCamara'+data.msg_id+'" class="commentCamera" title="Upload Image"><i class="fa fa-camera commentCamIcon"></i></a>'+
            '</span>'+
          '</div>'+
          '<div class="margintop10" >'+
          '<a href="#" class="wallbutton commentButton" id="commentButton'+data.msg_id+'" c="'+data.created+'">'+Comment+'</a></div>'+
          '</li>'+
          '</ul>'+
          '</div>'+
          '</div>';

The problem is that it doesnt stores the file in the folder so it can returned it eventually. I t stores the path in the database but not the audio file in the folder. So i ll try something and get back

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.