473,434 Members | 1,432 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

Execute web page without loading

I'd like to build a function that is executed when someone clicks on an
image. Once clicked, I need some parameters passed to a URL which PHP
will accept and deal with database connections. Sounds simple, and is
simple. The only thing that stumps me is that I do not want that PHP page
loaded anywhere that someone would see it. And preferably no frames if
possible.

Any suggestions?

~ Matthew
Jul 20 '05 #1
3 4560
In article <pa****************************@syr.edu>, Metnetsky
<mi******@syr.edu> writes:
I'd like to build a function that is executed when someone clicks on an
image. Once clicked, I need some parameters passed to a URL which PHP
will accept and deal with database connections. Sounds simple, and is
simple. The only thing that stumps me is that I do not want that PHP page
loaded anywhere that someone would see it. And preferably no frames if
possible.

Any suggestions?

~ Matthew


Set an image tags src attribute to the php page, then hide the image.
--
Randy
Jul 20 '05 #2
I think that you're talking about javascript remoting. I also wish there
was a way to do this. Ideally we could have a php script that reports db
data and have javascript get this data from a url. The only problem is that
if anyone was to send their browser directly to the url that reports the db
data they'd see all the data returned from the db and not the data that we
want them to see on the calling JS page. Let me know if you find any
answers. I've been working on this one for weeks.

Tom

"Metnetsky" <mi******@syr.edu> wrote in message
news:pa****************************@syr.edu...
I'd like to build a function that is executed when someone clicks on an
image. Once clicked, I need some parameters passed to a URL which PHP
will accept and deal with database connections. Sounds simple, and is
simple. The only thing that stumps me is that I do not want that PHP page
loaded anywhere that someone would see it. And preferably no frames if
possible.

Any suggestions?

~ Matthew

Jul 20 '05 #3
Metnetsky <mi******@syr.edu> wrote in message news:<pa****************************@syr.edu>...
I'd like to build a function that is executed when someone clicks on an
image. Once clicked, I need some parameters passed to a URL which PHP
will accept and deal with database connections. Sounds simple, and is
simple. The only thing that stumps me is that I do not want that PHP page
loaded anywhere that someone would see it. And preferably no frames if
possible.

Any suggestions?


Sure. The <script> element allows you to specify a URL in the src
attribute. Most people just put [somefile].js, but it can actually be
something like "getCustomerData.php?nameToFind=met&searchType=lea ding".
The key is that the PHP page (or ASP, JSP, or whatever) must return
JavaScript, not HTML, because it is going to be fed to the JavaScript
interpreter. That solves the first problem, which is how to get
information from the server to the page without causing it to refresh.

The next problem is how to dynamically invoke that method.

var nameSearchElement;
var nameSearchResult;
function doNameSearch ( nameToSearch ) {
if ( nameSearchElement != null ) {
document.body.removeChild ( nameSearchElement );
nameSearchElement = null;
}
nameSearchElement = document.createElement ( "SCRIPT" );
nameSearchElement.src = "getCustomerData.php?nameToFind=" +
encodeURIComponent ( nameToSearch ) + "&searchType=leading";
document.body.appendChild ( nameSearchElement );
}
function doNameSearchComplete ( ) {
// process the nameSearchResult object
}

The doNameSearch function creates the script element, attaches it to
the current document, which in turn causes the browser to ask the
server for the source of the script element. This establishes
communication back to the server and allows you to retrieve the
results.

The server code must return valid JavaScript code. In this example, I
have created a global variable "nameSearchResult" so I know where to
look for the results of the search. It is up to you to define how to
structure that data. This example also defines a callback function,
"doNameSearchComplete", used to signal that the operation is complete.
So, for example, the page could generate the following code:

nameSearchResult = {
numNamesFound: 0,
error: "Database currently unavailable"
};
doNameSearchComplete ( );

The last line invokes the callback function, indicating that the
server roundtrip is complete. Unfortunately, the database was down...

The good thing about this process is that it does not require
plug-ins, ActiveX objects, proprietary calls to internal components,
etc. Just good, old DHTML. The extra sweetener is that you get raw
data as executable code, not HTML or XML that has to be parsed and
then reformatted by other code.

Hope that helps.
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: denis | last post by:
after publishing a web to iis, asp pages based on a database fail to work. the browzer starts loading such page and never does- at some point the status bar stops and the page never loads without...
3
by: Chris | last post by:
I have yet to understand or get a response on the issue I'm having. I'm taking an asp web application and migrating it from Windows 2K to 2003. I have the new website location (2003) settings...
2
by: Sike | last post by:
Hi everyone, I've been browsing this and a few other related newsgroups trying to get my head around this problem, and so far all the trails seem to go cold, without an acceptable solution being...
31
by: Manfred Kooistra | last post by:
If I have a document like this: <html> <head> <script language=javascript> window.location.href='file.php'; </script> </head> <body> body content
3
by: Daz | last post by:
Hi everyone. I am making a stand alone web application, that listens for when the DOM content of a frame is loaded. Once it's loaded, I would like to stop the frame from loading further, as I...
8
by: M.L. | last post by:
Hello. I created a form using JS validation with the form tag as follows: <form name="form1" action="dynaform.php" method="post" onsubmit="return pvg_sub();"> The js validation script sends...
3
by: The alMIGHTY N | last post by:
I have an XSL file that works with a typically large XML data set generated dynamically from a database. This data is written to the HTML result as a deep multi-dimensional array that is used by...
3
by: Go Live | last post by:
Whenever i try to accecc HTML page through server.execute, i got this error. Server object error 'ASP 0228 : 80004005' Server.Execute Error server.execute("/folder1/htmls/" & strfilename &...
3
by: vingomail | last post by:
Loading pages should be showed before the next page data are loaded. help me friends. How may i know calculate the next page controls are loaded? Is there any methods to find out this problem? ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.