User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 423,621 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,189 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

javascript not working for firefox!

Join Date: Jul 2006
Location: Deptford, London
Posts: 954
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 48
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: javascript not working for firefox!

  #10  
Aug 30th, 2007
You can't read the data you have in your C# server app from the javascript code running in the client. A common way to 'get' data from server apps to javascript is to write the data values directly into the generated javascript code in a response... I don't know any C#, but I'll pretend C# is C++:

( in part where outputing the page data )
  1. std::vector < std::string > the_cpp_array;
  2. some_function_to_populate_the_array( the_cpp_array );
  3. std::cout << "<script type='text/javascript'>\n";
  4. std::cout << "var the_js_array = new Array( ); \n";
  5. for( int i = 0; i < the_cpp_array.size( ); i++ )
  6. {
  7. std::cout << "the_js_array[" << i << "] = '" << the_cpp_array[i] << "';\n";
  8. }
  9. std::cout << "</script>";
thus, if 'the_cpp_array' was filled like: { 'hi', 'I', 'am', 'an', 'array' }
then the generated javascript would be:
  1. <script type="text/javascript">
  2. var the_js_array = new Array( );
  3. the_js_array[0]='hi';
  4. the_js_array[1]='i';
  5. the_js_array[2]='am';
  6. the_js_array[3]='an';
  7. the_js_array[4]='array';
  8. </script>
That code could then run on the client, and the javascript could access the data. That assumes that you're generating the page content from within C#.. Erm.. sorry if you can't translate that from C++, I can't translate it to C#.

You might get a more useful answer from the C# forum.
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
All times are GMT -4. The time now is 9:15 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC