Click here to Skip to main content
15,912,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,I have file that stored into the root dirctory ChatFiles folder ,and want to assign to jquery function using label of asp.net.Suppose my file path is "~ChatFiles/abc.html",I Stored it to Label "lblFileName" from database,So how to assign it to jquery function.I have tried with following code but it throws exception that 'File path does not found',so how could i solve this,My code is...

JavaScript
function loadLogRefresh(){  
  
 var FileName = $('#<%=lblFileName.ClientID %>').text();

        $.ajax({
            url: FileName ,
            cache: false,
            success: function(html){       
                $("#chatboxRefresh").html(html); //Insert chat log into the #chatboxRefresh div              
            },
        });
    }


So how could i get exact path of file and pass to jquery function
Posted
Comments
When you debug, what value you see on variable FileName?

1 solution

Try this, tested ,working fine..
some syntax problem and file name suffix you have to take care of.

XML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script src="jquery-1.10.2.js" type="text/javascript"></script>
    <script type="text/javascript">

        function loadLogRefresh() {
            var FileName = $('#<%=lblFileName.ClientID %>').text();
            $.ajax({
                url: FileName,
                cache: false,
                success: function (html) {
                    $("#chatboxRefresh").html(html);
                }
            });
        }


    </script>
</head>
<body>
    <form id="frm" runat="server">
    <asp:Label ID="lblFileName" runat="server" Text="../ChatFiles/abc.htm"></asp:Label>
    <br />
    <div id="chatboxRefresh">
    </div>
    <br />
    <asp:Button ID="btnRefresh" Text="refresh" runat="server" OnClientClick="loadLogRefresh(); return false" />
    </form>
</body>
</html>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900