May be this is the code you are looking for :
var fileName = ''; var fileTitle = ''; _spBodyOnLoadFunctionNames.push("LoadAction"); function LoadAction() { GetFileDetails(fileID); // File Title if(fileTitle != undefined) document.getElementById("txtTitle").innerHTML = fileTitle; // File Name if(fileName != undefined) document.getElementById("txtName").innerHTML = fileName; } function GetFileDetails(itemID) { var temp_fileName = ''; var temp_title =''; var query = "<Query><Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>" + itemID + "</Value></Eq></Where></Query>"; $().SPServices({ operation: "GetListItems", listName: "Project Files", CAMLViewFields: "<ViewFields>" + "<FieldRef Name='FileLeafRef' />"+ "<FieldRef Name='Title' />" + "</ViewFields>", CAMLQuery: query, async: false, completefunc: function (xData, Status) { var xmlDoc = $.parseXML(xData.responseText); //$(xmlDoc).find("z\\:row").each(function(){ $(xmlDoc).find("[nodeName='z:row']").each(function(){ temp_fileName = $(this).attr("ows_FileLeafRef"); temp_title = $(this).attr("ows_Title"); }); } }); fileName = temp_fileName == '' ? '': temp_fileName.split(';#')[1]; fileTitle = temp_title; }