Ajax :: Write String To IFrame As XML Without Server-Side Scripting
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.
I have a script that writes to an IFRAME, it writes dynamically and then needs to reload it server side. Anybody knows how to do it? I'm joining the code of my attempt but it appears to be reloading the IFRAME on the client side therefore causing an activeX error since I am running this in FireFox:
From WebForm1.aspx, I have successfully retrieved a string that is dynamically generated in WebForm2.aspx and spit out to a Literal control in a div. This is what I did.
That's pretty simple and easy to understand for you jQuery gurus out there.
Now, I am trying to do the same thing within the single web form. That is, in WebForm1.aspx, I have this jQuery script to post to the same web form (i.e., WebForm1.aspx), but it is not working. Postback works OK, but I am not able to retrieve the dynamically generated string and spit it out to mydiv.
What's the jQuery way to do this? Any example? I searched, but I've only found examples which try to get static string values, which I know how to do.
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?
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?
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...
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",
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.
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.
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>
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.
I am totally new to jQuery and no good knowledge on javascript. However, I was assigned a task, to convert a javascript program to jQuery due to compatibility problem on browsers like Chrome and Safari. My program originally use javascript xmlDoc.load('....') to read XML file, and then use document.write statement to write html tables on client side. Something like this (the sample below may got lots of syntax problem as I jut want to show the major part):
Code: document.write('<TABLE >'); var y=x[0].getElementsByTagName('NoOfRows'); for (i=0; i<=noofrows-1 && i<=y.length-1; i++){ document.write(' <TD>'); document.write(z[j].getElementsByTagName('RecordDetails')[0].childNodes[0].nodeValue; }
Now I changed to use jQuery, I can read the XML file elements. However, when I try to write the table, it failed:
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.
I am having a query on javascript dialog box which gets thrown on "onbeforeunload" event. i.e "leave page .. " or "stay on current page" is it possible to change the caption of these buttons using client side scripting?
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)
I have the following client-side Content Management System VBscript which works great, now I'm looking at getting it to work server side so that I can update using online login rather than offline and having to upload files. To be honest, I have no idea where to begin with this,
I'm working on a project at the office that pulls together a bunch of our websites into a portal thing and adds a better search engine. We're also trying to accomadate newer browsers (Netscape 7.2, Firefox, Safari) and are having some problems. The websites run on different servers, all of which we control, so we are setting the document.domain = "ourdomain.com"; in some javascript on ever page. However, we're having problems. We use popup windows for some things, and sometimes these popups want to 'populate' the parent frame window with a new page as a result of a user selection on the popup.
This works most of the time, but not always. For instance, in Netscape 7.2 it just seems to fail with an "access denied..." error in javascript. In Firefox and Safari it opens a new window and populates that instead of populating the original parent window. Can anyone point me at some definitive information about the document.domain property and how to use it effectively?
How can I make the button call the click event so that the server side method btnExecute_Click() can be called? Also, this button calls a javascript function before server side even.
I'm trying to dynamically set the height of my Iframe. my https: main page is calling another https in an Iframe. But i get an access denied error from my javascript trying to call the parent document.
Main https page <IFRAME APPLICATION="yes" style="width:100%;" id="iframename" frameborder="no" scrolling="no" SRC="https://www.otherdomain.com">
otherdomain.com html ------------------------------------------------ <script> function bodyheight() { x = document.body.scrollHeight parent.document.all.iframename.style.height = x } </script>
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