PHP & JavaScript Communication
Feb 24, 2006Let's say I want Javascript to call PhpScript.php?Somevar=Somevalue and display the info. How do I get the php returned data in a Javascript var.
View 4 RepliesLet's say I want Javascript to call PhpScript.php?Somevar=Somevalue and display the info. How do I get the php returned data in a Javascript var.
View 4 Replieslet's me explains my long problem:
I'm doing an intranet with a media part. So im must be able to upload files on
a ftp server AND have a record of informations about this file and meta date in
a MySQL database, shown in a php page.
So the first thing i was doing was:
1/ * A HTML Form, with a <input type="file"> which was uploading the file to
the web server. And then, in the next action-php-page, using ftp functions from
php to upload to the ftp server. But this make upload the file 2 times, which
slow, and the user can't do anythig except waiting in front of a blanck loading
page.
=> no way
(BTW, the site admin refuse that the ftp server and the web server to be the
same computer)
So i tried something else:
2/ * A HTML form, the user enter meta data about the media, click next, and
then, a php page which loads a java applet an pass informations to it (by param
tags).
The applet have a browse button, and a go button, which start the transfert
(JDK 1.4.1) trough the URLConnection. The file is uploaded once, and there is a
progress bar, which is wonderful.
But now, i need the src_file information wich is the java applet. So i have two
options:
A/ I make a post to the webserver from the applet. But i'm using session
identification (needed for tracing users actions) and i'm gonna use SSL in less
than one month, so i think it would be complicated.
B/ I export the information from the java applet to javascript, and then to
HTML hidden field, so that the user can submit the full-hidden-filled form. But
i can't make LiveConnect works.
i'm under Mac OS X 10.2 (jaguar) so i need to make work LiveConnect on both
Safari 1.0 (v85.6), mozilla 1.5, and Mac OS IE (5.2).
I have set of frames... one contains a menu and the other a status frame. I am calling a function from the menu which sets the variables however I need some help passing those variables to the status frame. How would I go about doing such a thing?
This is called from the menu in frame 1 but doesn't work:
Code:
function jumpsec(cat, prod) {
parent.statusbar.category=cat;
parent.statusbar.product=prod;
}
// then my status frame bar has:
document.write(parent.statusbar.category);
document.write(parent.statusbar.product);
The 2 variables are blank on statusbar onload but get populated with each click.
I need to fix the communication between the JS located in this page and the PHP form script. When the form is submitted I want the page to automatically update which is already present in the script, thanking the user for the submission. Since the PHP script was changed that communication is broken and I hope to get it communicating once again.
View 2 Replies View RelatedHow can I inform a Javascipt, that must submit my Applet's data, that this same Applet has produced the data in question? Or in other words, is there any way to call a JavaScript junction within the Applet? Is it the best way? What do you suggest?
View 1 Replies View RelatedI am very new to web development. I would like my website to have an application which allows a user to draw images which can be displayed on other users screens in real time.
An example of this is isketch.net Also on this site i would like users to be able to create accounts and join 'rooms' where they can communicate in real time (as opposed a forum message board). I am looking for something similar to isketch.net
Could somebody please tell me the type of development and programming needed. I have been quoted 1000 a month to build these capabilities but have no idea what is involved. (also may require facebook style real-time updating)
How to do serial port communication using Javascript?
View 2 Replies View RelatedI am new to Javascript and am trying out window communication with a popup.In the main window it opens up a popup window with a button click. The popup window is trying to grab text from the main window and put it in it's (the popup's) window. I guess it needs a test to see if the window is ready??Here's the code:
<html>
<head>
<title>Main</title>[code].....
I'm trying to find a way to have a script communicate with a server
without having to load a new page. The idea is to have the server act
as a simple wrapper for a database, letting the client do that icky UI
stuff.
I tried the obvious, putting a frame somewhere it doesn't insult the
eye, changing its location, then accessing the new content via DOM.
What I get from IE (6) for my pains is just a rude "permission
denied". This even though I entered "localhost" as a trusted site in
IE's security setting. What's amiss?
I have a web app with a game and chat updating with ajax very frequently sending thousands of XHR requests to the server during a user's session. The problem is that most clients experience intermittent connection failures or timeouts. On the server it appears to be fine, all requests are logged to have completed successfully and on time but the client gets either a communication failure or a timeout. This makes the user feel like the game or chat just got stuck.
I use YUI for making the XHR calls but I replaced that with jQuery with exact same results. I make sure that only one query is active at a time, so I am sure that I am not hitting the max 2 connections problem. The failure rate may be 1 in 200 hundred requests or something but it seems that when a client has a failure then it fails at a higher rate, say 1 in 10 until the problem goes away. I have clients send back an error request when such errors happen in order to track the problem. I have tried various things to try to figure out what is wrong but I have not found anything. I don't think that it's the client's connection as it happens to a sizable portion of my users, it doesn't look like it's the server either.
So what I am wondering is whether this failure rate is common or expected when doing heavy ajax staff and I need to find a way to work around it or this must be a problem in my system that I need to figure out. If the latter any pointers where to look at?
I have given snippet of code in that it is cgi file in which i am using iframe , source of iframe is calling another cgi file. JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
Code:
Is-it possible to modify a window from an another window without having a
link Parent To Child?
I have need to communicate between two iframes of the same domain, which live inside a parent page on a different domain that I have no control over. This is a Facebook app and the basic layout is this
apps.facebook.com/myapp
L iframe1 (src='mysite.com/foo')
L iframe2 (src='mysite.com/bar')
I need frame1 to talk to frame2, but in Opera I can't access window.parent. frames['frame2'] to do the usual cross-domain methods (updating location.hash for example) Is there an alternate way to accomplish this in Opera?
I am working on a robot project, that is required to create a website to control the robot via serial port.. The website is plainly html, no linking to database is needed...
I have no idea how and what language to use and can JavaScript communicate with serial port? and how?
By having this...
And then, this:
PHP Code:
I can't get the "ola" to show on the page when I do a refresh.
I'm getting "bar undefined".
I do have a lot of simple and quick questions, but I will make just one:
Why am I getting "bar undefined" ?
I'm working on some code and am running into brick walls. I'm trying
to write out Javascript with Javascript and I've read the clj Meta FAQ
and didn't see the answer, read many similar posts (with no luck
though), and searched through the IRT.ORG Faqs
(www.irt.org/script/script.htm).
The Javascript is designed to open an popup window and then inside that
window call another script which will resize that window. There may be
another way around this but the reason I tried this approach initially
was that I wanted to call the onload handler in the popup window to
resize the image only after the image had completely loaded. I've had
some code in the primary Javascript file (showimage.js) before that
works if the image has been cached but on the first load, it doesn't
resize properly which tells me it is probably because it is trying to
resize the window based on the image size but it isn't completely known
at that point. So I removed that code and tried placing the resizing
code in the second Javascript file (resizewindow.js). BTW I've tried
other code to open a popup image and automatically size it ie Q1443 at
irt.org but that doesn't do exactly what we need.
Even if there is another way to do this with one file, I still want to
figure out why this isn't working in case I run into it in the future.
I thought what I would need to do to use document.writeln to write
Javascript would be to escape any special characters and to break
apart the script tag ie
document.writeln('</SCRIPT>');
would become
document.writeln('</SCR' + 'IPT>');
I have a HTML page and 2 Javascript files. All files are in the same
directory and have permissions set correctly.
Here are the 3 files (keep in mind wordwrap has jacked up the
formatting):
index.html
----------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test</title>
<SCRIPT type="text/javascript" LANGUAGE="JavaScript1.1"
SRC="showimage.js">
</SCRIPT>
</head>
<body>
Click the house<BR>
<A ONCLICK="newWindow1('house1.jpg','Nice House')"><IMG
SRC="house1thumb.jpg"></A>
</body>
</html>
showimage.js
------------
function newWindow1(pic,sitename)
{
picWindow=window.open('','','width=25,height=25,sc rollbars=1,resizable=1');
picWindow.document.writeln('<html> <head>');
picWindow.document.writeln('<SCR' + 'IPT type="text/javascript"
LANGUAGE="JavaScript1.1" SRC="resizewindow.js"></SCR' + 'IPT>');
picWindow.document.writeln('</head>');
picWindow.document.writeln('<body onload="resizewindow();">');
picWindow.document.writeln('<img src=' + pic + '>');
picWindow.document.writeln('</body> </html>');
picWindow.document.close();
}
resizewindow.js
---------------
function resizewindow()
{
// Do resizing here.
// Right now this isn't being executed
alert("resizing window");
}
Can anyone provide some pointers as to why this javascript is failing?
I'm using IE6 on Win2k and when I click on the image to open the popup
window, it does open the window but it is white with no content and the
system immediately goes from about 4% CPU usage to 100% and
consistently stays there until I kill that window with the task
manager.
Attached is a simple HTML file that adds and delete rows. In the add
row function I set an attribute "onClick" this triggers the
testMessage() function. When I try this in Firefox it works just fine
however on IE it just refuses to work.
What is interseting is the ROW that already exists has a similar
'onClick' event which works when the page is loaded, but subsequent
"row" additions to the table to not work in IE. Code:
two possibilities or the attribute type of script:
text/javascript (the one i usually use) application/x-javascript
what are the differencies between both?
depends on the html content?
for example html 4.0.1 versus xhtml 1.1?
I'm getting errors in Firefox everytime I try to run this frame resize code, but it works fine in IE. I can't seem to figure out what the problem is with it.
The error is: Error: theFrame has no properties
Line: 8
The line that the javascript console is showing an error for is in italics.
code from page:
<html>
<head>
<script type="text/javascript">
var defaultCols="100px,*";
var hiddenCols="0px,*";
function ShowHideMenu(){
theFrame = document.getElementById("framed");
if(theFrame.cols == defaultCols) theFrame.cols=hiddenCols;
else theFrame.cols=defaultCols;
}
</script>
<frameset cols="100px,*" name="framed">
<frame src="lframe.htm" name="frameMenu">
<frame src="mframe.htm" name="content">
</frameset>
</head>
<body>
</body></html>
Come someone let me know what I'm doing wrong here?
I'm already past the basics of Javascript, and i need something that takes me to the other level and teaches me the new technologies and cool stuff (drag&drop, AJAX, OOP in javascript, maybe XUL...etc). So far i found these two books:
1. Sitepoint's "The JavaScript Anthology: 101 Essential Tips, Tricks & Hacks".
2. Worx's "Professional JavaScript for Web Developers (Wrox Professional Guides)"
Both seems to cover very insteresting topics, but i can only buy one of them. So which one do you suggest?
and by the way, i've read the sample chapter 5 of Sitepoint's book, and it seems like the author(s) just put the solutions/codes there and let you figure them out on your own. Is this how the rest of the chapters are?
This is a question about defensive web browsing. Ocassionally I run into a page whose JavaScript does something that I find obnoxious. I would like to turn off JavaScript only for that page (instead of disabling it globally). It would be cool if there were some way to do this through a "bookmarkable" JavaScript snippet using the javascript: pseudoprotocol. Does anyone know any trick to do any of this?
View 2 Replies View RelatedI am looking for a method to extract the links embedded within the
Javascript in a web page: an ActiveX component, or example code in
C++/Pascal/etc. I am looking for a general solution, not one tailored
to a particular page/script.
Hopefully, the problem can be solved without recreating a complete
Javascript interpreter. Any ideas?
I have some javascript that I have written into the <body> section and it works great. But I would like to make it into a javascript function and define the function in the <head> section. Then in the <body> section write a small bit of javascript that would call the function() object. Code:
View 2 Replies View RelatedI would like to know how to write javascript such that, a part of it isnt considered as script, & rather as HTML. Code:
Ok, the layer div can be written using document.write. But, Google ad itself is a javascript isnt it. How can it be written into this? How does this work?
Ok so, this is my purpose:
- to be able to load asynchronously (via AJAX) some javascript ads (like google's or adbrite) so as to make them be loaded in the background, then update the page after the ads have loaded via innerHTML
Why?
-Because 90% of the time in my newer sites, javascript ads are the major offender in terms of speed of page rendering
My problem:
Via ajax, I can call a php file that retrieves some javascript and outputs it, XMLhttprequest returns those javascript lines, but they don't render in the page, since they miss the whole page loading, and are apparently not parsed
For example, let's say I call a php file via ajax, and it returns the output into a variable named "text" containing "document.write('hello')"
if I use xxx.innerHTML=text, nothing happens
My 1st solution:
Passing those javascript lines to eval() [like eval(text) ], but this produces a second problem, that I couldn't solve (probably because of my lack of knowledge in javascipt):
if I eval the code, it deletes my current page and renders a new one
for example, if I parse a document.write, my page disappears, and a new one is rendered with the document.write text
What I want is basically to make that "document.write" appear inside a div in my page, adding to the content (and not overwriting the whole page), much like what happens when using innerHTML
Is this even possible? How would you go about it?
I tried xxx.innerHTML=eval(outputfromphpfile) but it overwrites my whole page...
Just a quickie: is it possible to place javascript within javascript? The following is the code I am using to create a pop-up for a picture gallery. I would like to place a banner from a banner exchange in bold under each photo. When I use the code below I get an error message:
<SCRIPT language=JavaScript>
<!--
function openpic(pic_name) {
myWin= open("", "displayWindow", "width=640,height=510,status=no,toolbar=no,
menubar=no,scrollbars=yes,resizable=yes,alwaysraised=yes");
myWin.document.open();
myWin.document.write("<html><head><title>" + pic_name + "</title>");
myWin.document.write("</head><BODY><center><TABLE CELLPADDING=Ɔ' CELLSPACING=Ɔ' WIDTH=òr'>");
myWin.document.write("<br><img src=kate/image"+ pic_name + ".jpg><br>");
myWin.document.write("<br><br><BR><br><BR><br><BR>");
myWin.document.write("<script language='javascript' type='text/javascript' src='http://www.linkbuddies.com/ad.go?id=134039+2&n=3'></script>");
myWin.document.write("</center></body></html>");
myWin.document.close();
}
//-->
</SCRIPT>