I need to call a Javascript function from the server side in Client side. I looked and didn't find any way how to do it. I looked also over AJAX but can't figure it out. I am using ASP ( clasic) not .net .
I need to call the function in client-side with a variable that comes from the client-side. Please help me!!! Thanks a million !!!
I am using a FlashMovies that is sending a value to a Javascript function through ExternalInterface class. The function in javascript receiving it is gAnswer(result) and in this function i would need to have something like :
Server side: function saveResult(result) {code to be saved on the server goes here }
Client side : function gAnswer (result) { saveResult(result) } <- THis is the part i dont know how to do.
The function gAnswer is being called when the flash movie finished by itself. Would you be able to provide some code on how to ? thanks to each one of you who helped me =)
You can't call a function on the server from the client.
By stage 4, the program generating the page will have terminated.
If you want something to happen on the server based on a client side script executing, then you need to make a new HTTP request. There are lots of ways you can do this:
src
or an iframe <img>
and include the data in the src
Call serverside function from client side via Ajax using this here:
function CallServersideFunction() {
url = "CmsAjax.asp";
if (window.XMLHttpRequest) {
http = new XMLHttpRequest()
}
// code for IE
else if (window.ActiveXObject) {
http = new ActiveXObject("Microsoft.XMLHTTP")
}
if (http) {
http.open("GET", url, true)
http.onreadystatechange = handleHttpResponsearticleID;
}
isWorking = true;
http.send(null);
}
function handleHttpResponsearticleID() {
if (http.readyState == 4) {
if (http.responseText.indexOf('invalid') == -1) {
var xmlDocument = http.responseXML;
fno = xmlDocument.getElementsByTagName('id').length;
if (fno > 0) {
alert('Successfully done.')
}
}
}
}
On this page "CmsAjax.asp" you can do your serverside operations.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.