Link to home
Start Free TrialLog in
Avatar of YZlat
YZlatFlag for United States of America

asked on

Using AJAX to call classic ASP function

I have a classic ASP page that has a textbox, a div to display search results and a button on it and an asp file (Functions.asp) that contains the function that takes three arguments: A path to a folder, a search term, and a path to the temp output file. The function then searches all the files in that folder and subfolders (recursively) and writes each line that contains search term to a file, along with filename and line number.

Now what I am looking to do is initiate an AJAX call when button on the page is clicked to call the function from the Functions.asp file and read the data from the temp output file and display it on the page as it appear in the file (not waiting till the asp is done writing search data to the file.

I got all the asp functions working and just need help with the AJAX part. I have not used AJAX and classic ASP in good 8-10 years. Can anyone help?

Below is my javascript code that gets called when button is clicked:

function btnSearch_onclick(el) {

			if (!txtSearch.value.length) {
				alert ("Please enter text to search for.");
				txtSearch.focus();
				return false;
			}
			
			// Disable this button
			el.disabled = true;
			
			// CLEAR RESULTS
			$('SearchResults').innerText = ""
			
			// ajax CALL
			var request = new AJAXRequest();
			request.URL = "AJAX/Functions.asp"
			request.PageData = "searchText=" + txtSearch.value;
			....
		
		}

Open in new window


Not sure if what I am doing is correct and how to call the function FileSearch in my asp file, and how to pass the rest of the arguments - folder path and output file path...
Avatar of Charles
Charles
Flag of India image

Hi Good day,

Just gone through your requirement,

As per , What you want is, When writing the search results to a temp output file simultaneously same is to be loaded to the search page inside result div,

Here the problem is, if we try to access the same file simultaneously means error will be thrown,

So there is a simple workaround is there in this particular case , When you click search button If the functionality called will be running in a popup means, you can assign the result content to the opener page using javascript as below

window.opener.document.divid.value=<%=AspResultvar%>

Please try this, Also still you want AJAX that also possible, Please do reply with your code will check and revert back

Happy Coding
Avatar of YZlat

ASKER

Hello. Thanks for your response. You have lost me there...
"When you click search button If the functionality called will be running in a popup means, you can assign the result content to the opener page using javascript as below

window.opener.document.divid.value=<%=AspResultvar%>"
Avatar of YZlat

ASKER

All I want to do is when Search button is clicked to call my ASP code that is on another asp page and display search results to the page
ASKER CERTIFIED SOLUTION
Avatar of Charles
Charles
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial