Simple Ajax Issue

anandknr

Member
Hi All,
I was a php developer and now migrated to openedge.
I have query regarding making the Ajax working.

I have a main file and ajax file,anandtest.w(means the code working when making Ajax call and returning the html back) .
I have pasted below a common ajax function which i used with PHP.

function ajaxFunction_sup(div){
var param;
param = "anandtest.w";
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){

if(ajaxRequest.readyState == 4){

document.getElementById(div).innerHTML= ajaxRequest.responseText;


}
}
ajaxRequest.open("GET",param, true);
ajaxRequest.send(null);
}



The content of anandtest.w is {&OUT} "<b> ajax worked. </b>" .


but when calling ajax function i am getting the error below
" WebSpeed error from messenger process (6019)
WebSpeed Agent Error: Agent did not return an HTML page (6383)"

What could be the issue?
 
it might be the 'old' content-type lack issue... as the .w seems to use embedded speedscript you might try to add the content type before sending any output and see if this works.

Code:
output-content-type('text/html').

[COLOR=#333333]{&OUT} "<b> ajax worked. </b>" .[/COLOR]

A Content-type header is mandatory for any content sent to the Web output stream. Otherwise, the Web server will probably return an error to the browser. The Web object templates already execute this function with a default Content-type of text\html.
 
When i used ajax called file as an HTML it got worked.
ie, anandtest.w is replaced by anandtest.html .

But why my .w did not worked here where as html worked,Any thoughts?
 
But why my .w did not worked here where as html worked,Any thoughts?

Yeah, there are some :)

As I've commented before if you use embedded speed-script you have to specify the content-type otherwise the web server will throw you that error page, use output-content-type just right after you've set all the headers (you can't set any more headers once you used output-content-type, aka: set-cookie, set-header).

The HTML mapped object on the other hand has the content-type set to 'text/html' by default, that's why the .html file works while the '.w' doesn't.

You probably need to ask your senior developer for a minimum briefing on webspeed technology and what is the model used in your application, HTML mapped objects are not very popular among some of us and is better not to mix the two models in the same application :)

You can start asking what is the right model to use: embedded speed-script or HTML mapped, then related to your other post ask details about how the dynamic content folder structure looks like, how does the static content folder structure looks like, where is the server document_root and the application root folder... then you might go ahead and play with it, don't forget there is a help that comes with the installation :)
 
ohh... i missed your previous post.. i will try

output-content-type('text/html'). {&OUT} "<b> ajax worked. </b>" .

and let you know the output.

The problem is that our company is following a framework and we don't need to code for the pages,we generate it through framework,which i hate.
It seems like some sort of magic to me...I was trying to crack the webspeed technology .....thats why i am posting basic questions here...
 
Back
Top