Javascript question.. please advise?
Question by I Work For Jesus Online Everyday: Javascript question.. please advise?
Would this be possible through standard HTML and Java?
1. User clicks my ‘Products’ Link
2. My ‘Products’ page loads
3. A Java script in that page Loads ‘Currently Available’ product categories from a file on my server (ftp)
4. Product Categories are displayed
I was told that my web space does not support ASP, but I was also told it didn’t support Front Page LoL (don’t ask me)
What methods can i use to accomplish the task?
I need to implement a way of listing my current inventory as products available on my web space. For example, I add/sell an item and that item appears/disappears.
Thanks in advance!
Everyone have a good night.
Best answer:
Answer by asim_developer
yes that is possible with javascript
you can open a file from a server and can display it through javascript and AJAX
function CreateXmlHttp()
{
try
{
XmlHttp = new ActiveXObject(“Msxml2.XMLHTTP”);
}
catch(e)
{
try
{
XmlHttp = new ActiveXObject(“Microsoft.XMLHTTP”);
}
catch(oc)
{
XmlHttp = null;
}
}
if(!XmlHttp && typeof XMLHttpRequest != “undefined”)
{
XmlHttp = new XMLHttpRequest();
}
}
function uncache(url){var d = new Date();var time = d.getTime();return url + ‘&time=’+time;}
function Handlel()
{
//alert(XmlHttp.readyState);
if(XmlHttp.readyState==4)
{
if(XmlHttp.Status==200 || XmlHttp.statusText==”OK”)
{
document.getElementById(‘text’).innerHTML=(XmlHttp.responseText);
}
else
{
alert(“There was a problem retrieving data from the server.” + XmlHttp.statusText);
}
}
else
{
document.getElementById(div_id).innerHTML=”“;
}
}
function Main_func(url,type,id)
{
var requestUrl;
div_id=id;
global_rec_data_type=type;
requestUrl=url;
//alert(requestUrl);
CreateXmlHttp();
if(XmlHttp)
{
XmlHttp.onreadystatechange = Handlel;
XmlHttp.open(“GET”, uncache(requestUrl),true);
XmlHttp.send(null);
}
}
Regards
Asim
What do you think? Answer below!