Click here to Skip to main content
15,903,856 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi.
i'm trying to call j query function from java script.
i want to pass file name to
j query function which reads the content of the file and returns the result..
everything works fine for ie but i'm getting error in firefox as 'read undefined'
the function which i'm calling is undefined.
like...



//java-script function

JavaScript
function ReadFile()
{
//some code
var data= read(fileName);
alert(data);
}

//J query function
function read(fileName)
{
               $.get(fileName, function (data) {
                szData = new String(data);
            },"text");
        return szData;
}


------------------

Java

Posted
Updated 26-Nov-13 17:17pm
v6
Comments
Pheonyx 26-Nov-13 4:44am    
And what is your problem?

All you have stated is what you are doing, not what the issue is.
I assume it is not working, but have you tried to identify what error is being thrown? I would suggest looking in a web browsers development tools to try and catch it. In IE these can be accessed by pressing F12 or from the tools menu I believe. In Chrome they can be accessed with Ctrl+Shift+I
kedar001 26-Nov-13 4:47am    
all works fine in IE...
but not in firefox....
Pheonyx 26-Nov-13 4:50am    
Then check the firefox developer tools and see if an error is being thrown. I don't know anything about the firefox ones, but both Chrome and IE allow you to debug jquery so that might be possible and allow you to identify what is going on.
kedar001 26-Nov-13 4:58am    
thanks for your reply..
in firefox i'm getting error like "read undefined"
the jquery function which i'm calling is undefined..
[no name] 26-Nov-13 5:18am    
check with firebug add on for firefox, it shows the exact error

work on all browser....


JavaScript
function ShowReadFilecontent(objFileName) {
        var result;
        $.ajax({
            url: objFileName, 
            type: 'get',
            dataType: 'htm',
            async: false,
            success: function (data) {
                result = data;
            }
        });
        return result
    }
 
Share this answer
 
v2
I noticed an issue with this function, I don't know if it is causing your problem or not thought:

JavaScript
function ReadFile()
{
//some code
var data= read(fileName)
alert(data);
}


You have missed the ; off of the end of this line: "var data= read(fileName)"
 
Share this answer
 
Comments
kedar001 26-Nov-13 5:39am    
sorry... my mistake while posting

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