Javascript Server Variables?

Jan 18, 2007

I was handed a project that, when launched, had some ajax problems--specifically, "Error: uncaught exception: Permission denied to call method XMLHttpRequest.open." That's easy enough to fix--found the call in the .js file that was referencing the development server instead of the live server, and I am aware of Javascript's same-origin policy, which makes good clean sense. Change that call, problem solved.

Unfortunately, it's not solved. I can change the reference from
var url='http://www.devserver.com/function.php?id='+id;
to
var url='http://www.liveserver.org/function.php?id='+id;
but that doesn't solve the issue of if someone comes to the page without the 'www' or to the other domain, whose TLD is a .com instead of .org.

In PHP, I'd simply write the function to dynamically generate the url string, using $_SERVER variables rather than hardcoding the url. But I'm no javascript guy. Any help would be appreciated.

I'd rather not have to put a php redirect in every page to make sure the url is what I want it to be. I'd much rather learn something new about Javascript.

View 3 Replies


ADVERTISEMENT

JQuery :: Initializing Data Method Variables On Server Side?

Feb 8, 2010

You can use JQuery's data method (e.g. $('#MyID').data('MyVar', 'MyValue');) to easily store/retrieve information.

However, I was wondering if it is possible for my PHP generated page to add HTML tags that initialize the JQuery's data method variables. Regularly, I want server side variables to be accessible client side. It would be very helpful if I could initialize data method variables during PHP page generation.

If this is not possible, are there any suggestions on how to efficiently communicate server side variables to client side?

View 3 Replies View Related

PHP Variables To Javascript Variables

May 6, 2006

I have a program written in Javascript and fully functioning which takes a user-selected directory name and then displays all the photos in that directory in a certain format.

I am now wanting to expand the program to allow users to optionally enter their own strings and the program will use all the photos from www.flickr.com which use that string as a tag.

I have a PHP interface to flickr (called PHPflickr) which collects all the relevant photo urls. I now need to get these images back into my Javascript so I can process them using the existing functions (rather than rewrite all my functions in PHP code and have two sets of functions in the program). I found on another thread a means to do this for a date variable:

var jsArray = new Array(
<?php
$length = count($monthDataArray);
for ($i = 0; $i < $length; $i++)
{
echo '"' . addslashes($monthDataArray[$i]) . '"' . (($i < $length - 1) ? ',' : '') . "
";
}
?>

but being completely new to PHP I'm not sure what "addslashes" might be or what formatting will be necessary if I am starting with an array of urls. Code:

View 1 Replies View Related

Getting The Web Server Name Through Javascript

Sep 19, 2005

Is it possible to get the web - server name through Javascript? If yes, how?
My code goes as follows. I get an error after executing this

<html>
<head>
<title>Untitled</title>
<script>
function disp()
{
str1 = location.host();
alert(str1);
}
</script>
</head>

<body>
<cfoutput>
<a href="##" onclick="disp();">Click me</a>
</cfoutput>
<cfabort>
</body>
</html>

View 2 Replies View Related

Javascript On The Server Side

Jul 23, 2005

However, this piece of Javascript uses some other script which is large.

<script src = "./js/tmp.js".....>

This will work if the file "tmp.js" is local. However this reduces the
portability of my *utility* Javascript
as users have to have that "tmp.js" for every webpage they have (if they
want to use it :D)

I thought of uploading "tmp.js" it to somewhere and change my code to

<script src = http://www.somewhere.com/js/tmp.js ....>

The all the users have to do is copy the piece of code that I wrote
BUT THIS DOES NOT WORK. I TRIED IT.

My questions are:

1. Is there something wrong with server-side Javascript? Or am I missing
something?

2. Is there another way to make my code portable?

View 2 Replies View Related

Javascript And Server Socket

Feb 2, 2006

I'd like to implement a server socket in java: something linke the following example.

The problem is that the HTML has not the permission to execute instruction
serverSocket = Components.classes["@mozilla.org/network/server-socket;1"].
createInstance(Components.interfaces.nsIServerSock et);

Question:

1 - how do I give it this permisison?

2 - one solution I thought was to put the javascript code in a firefox
extension, to load, so it should have all needed permisison, but,
How can I call a java script function define in an extension
from an html page? - there's some particular syntax? ....

View 2 Replies View Related

Javascript Function In Different Web Server

Feb 16, 2006

I have three different web pages with different domains, and I want to
show some pages of one of the webs in the others.

I use an iframe for this and it shows it good until I have to call a
javascript function in the iframe inside page, I have a permission
denied because the domains of these pages are different.

So, the cuestion is:

Is there some way to call the javascript function of the iframe from
the parent page?

View 2 Replies View Related

Javascript Dies On IIS Server

Sep 29, 2006

The script below loads a calendar page in an iframe and scrolls to
today's date.

It works just dandy on my apache/linux server, but won't do anything
when I use IIS. (Nothing appears on the page at all where the script is
at.)

I'd appreciate any suggestions on how to make this work from the IIS
server. Code:

View 5 Replies View Related

JavaScript On The Server Side?

Nov 3, 2006

I might be turning a corner today and seeing the light. I might still
be confused :)

If JavaScript is the language for the browser then why do servers use
Ruby/Rails, Perl/Catalyst, Python/Turbogears or PHP/Cake? Is it because
the prototype-based language is too different to be chosen except when
necessary. Is it because browser bugs make people think JavaScript is
bad? Is JavaScript not suitable for the server-side for any reason?

I imagine that if server-side programmers started to learn JavaScript
then the client-side code in the world might start to improve.
Translation layer libraries like Prototype.js or Mochikit wouldn't need
to exist. The more I learn about JavaScript the more I like it. It is
difficult to learn however for multiple reasons.

View 5 Replies View Related

Accessing A Server From Javascript

Jul 20, 2005

I have seen web pages sites, when you drop down a list box, it seems to go
back to the server to retrieve some data without reloading the whole page
(e.g. select make of car and it retrieves a list of models from the server
to populate another list box).

View 1 Replies View Related

Javascript Variables

Feb 4, 2006

I have the following javascript function: Code:

function updateParent(dvalue, dfield) {
var field = dfield;
window.opener.document.form.field.value = dvalue;
alert("Value: " + dvalue + " Field: " + field);
self.close();}

I'm calling it as so:

<a onClick="javascript: updateParent(30,'image_id');">Update</a>
But I get the following error:

Error: window.opener.document.form.field has no properties

Why is it not picking up that I have defined the variable field as image_id?

View 2 Replies View Related

How Can I Run Server-side Javascript On Apache ?

Jul 23, 2005

I have a number of server-side Javascript applications running on an
old Netscape Enterprise server. I want to move them to Apache. Is
there a way to do this without extensive recoding ? My code contains
a lot of Oracle and SQL Server database interaction.

View 2 Replies View Related

How To Obtain Server IP Address Using Javascript

Jul 23, 2005

Is it possible to get the Server IP Address from Javascript

ie., when the user types "http://10.0.0.10/main.htm" in the web
browser, i need to retrive the value of the IP Address(10.0.0.10) from
my client side javascript.

View 2 Replies View Related

Remote Post To Another Server Using Javascript

Nov 23, 2005

I want to populate my client's webpage (Remote Server) automatically
through my Server and Database by having him just paste a javascript
on his webpage.

I have read up about Microsoft Remote Scripting but the documentation
states the following : "The server which you make remote scripting
calls must be the same server from which you requested the client page
containing the requests."

In my case , the client and server pages are on two seperate servers
which means that I cannot use MS Remote Scripting.Is there an alternate
approach in any scripting language ???

Any suggestions, tutorials , websites , code snippets will be
appreciated while i continue to research on this...

View 4 Replies View Related

HTTP Server Login From Javascript?

Aug 2, 2006

Ref. http://support.microsoft.com/kb/834489/en-us

Now that http://username:password@site.com no longer is an accepted
syntax in IE, I suddenly have a case in a project I'm working on. The easiest(?)
solution would now be that there was some Javascript function that
could pass the username and password or in som other way automate the login
process on a given site.

Thing is I have a server-generated HTML page that I want to make the
client redirect to a password protected site. (IIS Windows authentication).

Before: location.href='http://name:pwd@site.com'
Now: ?

View 3 Replies View Related

State Of Server Side Javascript

Jan 20, 2007

I'd like to adapt some Greasemonkey scripts that I've written and have
them applied to html files on the server side before the files are sent
to users. I'm only looking at adapting scripts that make static
changes to pages. For instance, consider a script that removes from
the DOM any img that has "ad" in its src.

I'm sure there are better ways to do this and I'm not even necessarily
looking for an extremely efficient solution. Mostly, I just want to
know if there's an existing product that could do this or with
reasonable effort could be made to do this.

View 5 Replies View Related

Controlling Javascript From Server Side

Aug 29, 2007

I want control a hardware device using a Web browser.
I created a page which has a form containing all necessary INPUTs.
By clicking a button, all current settings are sent to the server side
(using POST or GET) so that the server can interact with the hardware,
which is under the server's control.

Now, in some cases, I want to update the INPUT (w/ readonly) with the
data from the hardware, such as a status value.
Most primitive approach is creating a new page with new value to the
INPUT, where I want to show the value.

But that is not quite efficient as the page appearance won't change
except the contents of the INPUT.

As Javascript can make any change to the HTML page (at client's side)
that is currently being displayed, it is more straight forward if the
server can send a set of Javascript commands to the web server so that
it can just update the display contents rather than refreshing
everything.

I thought such scheme was already available, but so far, I don't see
anything usable.

The Web server is not a commercial one but a custom Web server
(written in Python) so that I want to keep the scheme as simple as
possible. I checked AJAX but I'm not sure I can use AJAX in my
application.

View 10 Replies View Related

How Can I Write Javascript For Server Controls?

Oct 13, 2005

I am a .Net Developer. I want to know to write javascript for serverside controles.And where it is placed for sever sidr controls. Please tell me if any one know this.

View 1 Replies View Related

Server Side Javascript Portability

Jun 8, 2005

How portable is server side javascript? Does server side javascript works the same across different browsers and operating system? What I should do to ensure it is more portable?

View 1 Replies View Related

Javascript Server.mappath Equivalent

Apr 12, 2007

I am using a location in my javascript: '../../myfolder/myfile.asp'

I want to make the script reusable by pages in different folders. The 'myfolder' is in the root of my site. How can I target this from any other folder such as the vbscript server.mappath('myfolder/myfile.asp')?

View 2 Replies View Related

Passing Javascript Variables To JSP

Jul 23, 2005

I need to pass a javascript to JSP code but I cannot figure it out.

View 2 Replies View Related

Bring Variables From Php To JAVASCRIPT

Jul 23, 2005

Does someone know how can we bring variables from a PHP script to a
Javascript one ?

I have to build a Javascript function that needs variables generated by a
PHP script but i do not know the way to retrieve them into Javascript.

View 5 Replies View Related

Question About Javascript Variables

Feb 23, 2006

I was just reviewing some javascript pop up window functions on my website and I descovered something... that I set the exact same variable name twice for both functions... which is bookWindow. I tested this for pages that use both functions and both types of pop windows work no problem. Is there a problem in that I use the same variable name twice? Is this considered bad form? Or maybe it makes not difference at all because the variable only gets used when it is
called upon and then it leave memory.....

View 2 Replies View Related

Images In Javascript Variables

Oct 30, 2006

I have some image data in a Javascript variable, and I want to display
it. I have a technique which works in Firefox but not in Internet
Explorer :

<script>
var testImage = <image data as a string>
</script>

<img src="javascript:testImage"></img>

I understand that this should work in Javascript 1.2 and above, which
supports null characters in strings. Does anyone know why this doesn't
work in Internet Explorer?

View 3 Replies View Related

Why Don't You Have To Declare Variables In Javascript?

Jul 20, 2005

can anybody put forward a sensible argument javascript's behaviour of
creating a new global variable whenever I assign to a previously undeclared
variable. I can't beleive this is just for the sake of convenience (surely
we learned this much from basic).

here's my proposal: all "global" (document scope) variables must be declared
by 'var' outside a function block.

failing that, does anyone know any patterns or tricks I can use to make sure
I don't create a new global variable when I accidentally misspell a variable
name?

View 10 Replies View Related

Retrieve CGI Variables From Javascript

Jul 20, 2005

Here's the situation. I have a static html page which we want to update
to include some dynamic content. I want a counter that keeps track of
the number of times anyone presses the "add" button, and display that
number. So, that page would look something like:

Number of calls today: 5
Add | Reset

The "5" would increment with every click of the "Add" link. The "Reset"
link would reset the counter to 0.

I have a Perl script that does all of the accounting stuff (opens a file
that contains the number, increments it, resets it, etc). What I don't
know how to do is to get the data from the CGI script to the web page.
I'm imagining that you can use Javascript, but I can't figure it out.
My CGI script can accept three options (add, view, reset). So it you
call it like so [myscript.cgi?action=add], it increments the counter by one.

So, in a nutshell, this is what I want:

1) the web page to display the # of calls upon load.
2) When a user presses the "Add" link, it invokes the CGI script to
handle the accounting stuff, then refresh the page with the new number
of calls.
3) When a user presses the "Reset" link, it resets the counter to 0.

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved