Server-Side HTML To JavaScript Vars In AJAX?
Mar 24, 2007
I want to load some pages generated with the server (ASP) and assign
their html results to JavaScript, so users could click the links and
the content of any selected page would show up immediately, making no
requests.
So, I have one main page called mainpage.asp which, I think, should
get all subpages with content, names are subpage1.asp, subpage2.asp,
etc. I tried ASP's XMLHttpRequest to get content of all sub pages and
assign html result to JavaScript variables. But I realized that MS
XMLHttpRequest does not get session protected pages. I mean that if my
subpage will generate output with session only, then even if the
session exists, MS XMLHttpRequest does not see it.
Anyway, this trick did not work. If I include these subpages in
mainpage.asp under a hidden field, this may be a solution but I do not
see it good enough yet.
What would you recommend? How would you assign subpage's html code to
JavaScript variables or array of variables?
View 3 Replies
ADVERTISEMENT
Jan 23, 2007
I'm writing a program on Zimki, which I think uses SpiderMonkey as a server side Javascript engine.
My idea is to have an html file that someone else created, and look inside for cells in a table that have special known names, like name, description, etc. Then I want to figure out the <tr<tr/pair that encloses all of those special tags, and use that as a template to generate a bigger table from another datasource.
So, I'm wondering how I actually open a file and then parse it as html so I can poke around the DOM, all from the server side without involving a browser client.
View 2 Replies
View Related
Jul 20, 2005
I have a Hyperlink within a String like below:
sSql = "SELECT DISTINCT " + "'Action' = '<center><a
href='+char(34)+'ChangeRequest.aspx?ID='+cast(Chan geRequest.ChangeRequest_ID
as nvarchar) +CHAR(34)+'>Open</a></center>',"
I want to invoke a Client side javascript function and pass the value
of the ID. How can I accomplish this such when a user clicks "Open" he
goes to a new window with the same ID.
I tried this but it does not work:
On Server side:
sSql = "SELECT DISTINCT " + "'Action' = '<center><a href= 'javascript:
NewWindow('+cast(ChangeRequest.ChangeRequest_ID as nvarchar)+
CHAR(34)+)'>Open</a></center>',"
On Client side:
function NewWindow(myID)
{
window.open("ChangeRequest.aspx?ID="+myID,"WindowName","width=500,height=600");
}
</script>
View 1 Replies
View Related
Apr 19, 2010
I'd been looking for some way to get server date/time without using any server side script (such as ASP, PHP, etc).
I found this and it worked just excellent for me! I just want to share it because it wasn't easy to find.
I created a js document with code:
Code:
Now, I can use this js within a html like this:
HTML Code:
You may change your machine date/time and check both dates.
View 1 Replies
View Related
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
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
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
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
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
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
Feb 12, 2007
I work for a financial company. I am planning to give a presentation
to rest of the development team (15 people) here on moving server side
logic to client-side javascript for an internal intranet application
rewrite. This approach will definitely stir up hot debate from
hardcore server-side Java folks who wants to do UI stuff even on the
server!. Since I am pretty much known as the JS or UI Guy of the
group, my Boss wants to hear the broad spectrum of PROs/CONs from each
proponent.
Personally, I think Javascript/Ruby is a more productive language than
Java.
My idea is simple. It is to convert most business logic to client-
side javascript and have calls to server-side code restricted to user
roles with data validation. Thats as simple as it gets.
Here are my list of arguments
1. True separation of UI logic from server-side data processing code
(no more server code spitting out client-side code)
2. Better user experience with faster response
3. The whole web 2.0 thing (no page refresh) :)
4. Offload client processing from server therefore reducing network
traffic (not really a strong argument is this?)
Keep in mind this is an internal app. Even if someone figures out the
JS logic behind the page and try to hack the app by posting to
Servlets, they will be restricted by their login role, and data
validation will take care of any bogus data being submitted.
View 14 Replies
View Related
Nov 14, 2006
can you put an id into a server side include like you can other items using javascript?
I tried this putting the id name in the virtual address area but it doesn't work. I also tried replacing virtual with id instead still with no luck.
document.getElementById('dynstuff').src=content[newm]
<!--#include virtual="dynstuff"--><!--#include virtual id="dynstuff"-->
The error message says getElementById is null or not an object but it works fine with image ids and iframe ids. Can anyone tell me why this doesn't work?
View 4 Replies
View Related
Oct 31, 2006
AJAX is a rich client-side technology that makes the web pages more
interactive. In practice, the same AJAX client-side code should be
unchanged, regardless of what server-side web technologies we use. I
guess this is same concept as traditional front-end plain html code
that can work with different server-side web technologies for back-end
processing.
Similarly, AJAX should be server-side independent concept,
is that correct? But if this is the case, why there are different AJAX
frameworks available for different server-side web technologies such as
Java, PHP? We should simply just use generic AJAX server-side
independent framework for our AJAX-enabled web applications.
I wonder what server-side technologies that google maps/gmail use for
their AJAX front-end?? I guess google maps/gmail can be good AJAX
models to follow?? What do you think?
View 1 Replies
View Related
Jul 23, 2005
I'm displaying a loggin page.
If the user entered an invalid UserName/Password I display the page again.
When this happens I want to give the user a different message then the one displayed when the page was initially displayed.
I use the Response.Redirect method from the page checking the submition.
When I do that I call the page with a parameter like this Response.Redirect("Page.asp?FROM=1").
When I get the parameter in the page I know I need to show a different message.
The problem is that if the page is called without the parameter, I
cannot determine that the parameter is missing.
The codse is very simple:
from_flag = Request.QueryString("FROM")
Now is the problem -
if I use if(from_flag == 'undefined') - this condition return
false.
but if I display from_flag using Response.Write(from_flag) I get "undefined"
if I use if(typeof from_flag == "undefined") - this does not work since the typeof return "object" in both cases when I call the page with the parameter or without the parameter.
also I tried to comnpare with null does not work.
By the way if I use VBScript as the script lang - it works fine I just need to compare the from_flag with vbNullString and all is well....
View 2 Replies
View Related
Jul 23, 2005
I have a few values and variables that I want to post to a server
(without using a SUBMIT button). Is there a way to post data from
within javascript - do sockets or connections have to be open for this
to work?
View 5 Replies
View Related
Nov 29, 2005
I am developing an ASP.NET (C#) application and need some help. I wish
to call a server-side function (in the code-behind "file.aspx.cs") upon
a user clicking on the "X" to close the browser window. Is there a way
to postback and call a server-side function when this happens? I am
aware of the browser's native "onunload" event, but am not certain that
what I'm looking for is actually possible.
View 2 Replies
View Related
Oct 28, 2010
I know that Javascript is client side, but I'd like to know the best way to populate HTML drop downs in real time based on information typed in the other HTML form fields with information found on the server as opposed to the client.For instance if a user wants to select certain files located in a directory on the server, as they type in the pathname supposedly containing the files the drop downs continually refresh themselves with the server files listed in that directory (if it exists, and apache has permissions to see what's inside) as if it was showing client files instead.
What would be nice is if my browser could continually query the server for some of its private information and not have to refresh itself to obtain it, whether that means the server-side would have to continually refresh itself makes no difference to me as long as the client-side doesn't have to. But I guess this is not possible because no matter what you would have to at least refresh the client-side page once?Submitting the form to a CGI or PHP script would not work because I need this functionality to help populate the form BEFORE I send it.I would like to not have to press a button to update the form every time I change the pathname and need to update the drop downs since this would be annoying.
View 2 Replies
View Related
Feb 22, 2010
My login to the site is being processed using ajax, which does a redirect to the members page upon succesfull loggin in.The login feature however can in fact take a while because we need to initialise quite some data when a user logs in (his details, but also his privileges are loaded, his personal menu based on these privileges are being loaded, we are loading shopping cart info, we are initialising personalisation settings, and a whole lot more.It sounds like a big thing, but it isn't, and once logged in, the application is going great. the only thing is that the login proceure can take 3 - 4 seconds, and I would like to be able to show the client the progress of the serverside script:
"Searching your account..."
"Validating your privileges"
"Initialising your personal menu"
blablabla...
To do this, I might just call an ajax call that starts the login procedure, and then issue another ajax call every 1 second or so to update the status based on some session variables I set in the login procedure and that I can serve to the client when th next ajax calls come in, but I would love for this to work a little nicer as in just needing to initialise ONE ajax call which can send back statusupdates from the server...
View 1 Replies
View Related
May 13, 2011
I am trying to write a string variable containing XML in the form of text into an iframe such that it shows up as formatted XML with the expand(+) and collapse (-) options that default in IE when opening an XML file.
The first thing I tried is writing the string to a file with .xml extension and setting the iFrame src to that file. This works well normally, however in this case, the file does not get created where I want to due to some security restrictions in IE which I cannot edit as I dont have admin rights.
Secondly I tried appending the string as innerHTML to that iframe but only the content within the XML tags without any formatting shows up which is not intended.
Thirdly I cannot use any server side scripting as this is a very controlled environment and I am not allowed to host servers or edit server scripts at will. This is totally out of question, so I guess Ajax or calling a costom defined web service wont help.
At best I can say, I am limited to HTML, Javascript and vbScript.
I am receiving the string as a responseText from an ajax request which is consuming a web service. If I use responseXML, it doesn't work.
The solution I am looking at is to either display it as formatted XML in an iFrame or to just throw it into a textarea which I am already doing and simultaneously write it to an XML file or do both. If not automatically, atleast have the user press a button and do it.
View 4 Replies
View Related
Apr 14, 2010
I want to send three text box values to server using jquery ajax. problem is that, i dont know the exact syntax to send three data. When i try sending one data(also change no.of parameters to one at server side method), its going good but when i try to send three text box values, its giving jquery error:"Internal server error". I think I am not sending data in correct way. Example below contains only two sending data, because i was trying to send 2 data first.
Below is the code:
function testCAll() {
$.ajax({
type: "POST",
url: "dbTest1.aspx/SendMessage",
[Code]....
View 2 Replies
View Related
May 26, 2009
I am building a client-side and server-side solution and want to use JSON through Ajax in both directions. I have ASP or JavaScript server-side, though Microsoft's support of server side JavaScript seems nil, so I am reluctantly conceeding to use ASP. I'd appreciate suggestions on available solutions to encode/decode JSON on the server-side (ASP or JavaScript). I don't plan to load jQuery server-side so that rules out plug-ins. I'd also like to know what is the latest client-side encode/decode for JSON. Is it built in jQuery or a plug-in? In both server and client, decoding JSON securely is key, so using eval () to decode is out.
View 1 Replies
View Related
Jun 1, 2009
I am developing a web form using python cgi which has two list boxes. On selecting a value from the listbox1, the list box 2 should get auto populated with appropriate values (which are taken from the DB). I have written a javascript function to get the selected value from the list box1. But I am struck with passing the values from the javascript to the python function written in server side in which I have written the DB related stuffs.
View 1 Replies
View Related
Aug 22, 2011
On the server side I have a php generated session parameter.
I need to pass it to javascript on the client side page.
I saw on the web the following solution code...
I tried it but it did not work.
View 1 Replies
View Related
Sep 11, 2009
I have the following PHP code, which uses server-side validation, which works fine. It the user leaves the text field empty it stores an error in a session array which is outputted on the page where the $_GET['id'] variable came from. I also implemented a snippet of javascript code that just checks to see if the cell is empty and throws up alert box. The problem is that both the javascript code and php error validation are both running when I click submit. The PHP code should be a backup to the javascript code in case the user has javascript turned off. The client-side validation should be the default. Not sure if this change should be made in my PHP Code or Javascript Code.
PHP CODE:
session_start();
require_once("../Modules/Connection_Functions.php");[code].....
View 1 Replies
View Related
Jul 20, 2005
I have a web form that has a checkbox on it and a textbox associated
with it. I want the textbox to be displayed when the checkbox is checked
and I want this to happen on the client-side instead of posting back to
the server. The checkbox is a server control (asp:checkbox...). I can
write some codebehind that will display an alert message upon checking
the box that looks something like this...
Page_Load...
Dim s As String
Dim scriptString As New System.Text.StringBuilder
chkExpDate.Attributes.Add("onclick", "alertmsg()")
scriptString.Append("<script language=JavaScript> function alertmsg()
{")
scriptString.Append("alert('hi'); }<")
scriptstring.Append("/" + "script>"
s = scriptstring.ToString()
Page.RegisterStartupScript("startup", s)
End Sub
I used this as a test to make sure the server control was running the
script. But, when I change the script to assess the value of the server
control checkbox such as checked = true, I get errors and if I just try
to display the asp:textbox, it doesn't work either.
View 1 Replies
View Related
May 14, 2007
I had a import function which allow for user import data from excel file. The number of row was dynamic, mean that user may import hundred or data or may thousand of line.
should i perform client side or server side validate?
the problem i faced was if the import thousand of line, i need display out thousand of text (multiple by 6, cause 1 got 6 fields)
the take a lot of time to loading and cause browser "hang" (response slow)
any solution for me?
View 13 Replies
View Related