In windows click on Start, then Run, type cmd and click on OK.
Starting the BSP.
Create a new BSP application, with two pages, display.htm and data.htm.
import prototype_min.js and json_min.js as mime object
create an empty my_handler.js and import it too.
It should look like that:
Do some HTML.
In display.htm just do a basic page :
Do some ABAP.
Gather some data from a random table and create some JSON : text like this :<br>
<textarea COLS=70 ROWS=10>
<%@page language="abap" %>
<%
DATA I_dude TYPE zdude.
data w_dude type line of Zdude.
data w_str type string.
CLEAR I_dude.
*get data from the table I_dude
select *
into table i_dude
from zdude.
*create the json text into the string w_str
concatenate w_str '{ "dude": [' into w_str.
data i type i. i = 0.
loop at i_bdude into w_dude.
if i gt 0.
concatenate
w_str ','
into w_str.
endif.
// a controller object that help us with a nice window to display a log var Controller = Controller.console.innerHTML += (message + "
"); } };
// what you execute when you run the page display.htm (look at the body tag) function Initialise() {
var url = 'data.htm'; var pars=””; //call the data.htm page to get our json object Ajax object comes from prototype var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete: showResponse });
}
function showResponse(req) { var myObject = JSON.parse(req.responseText); displayDude(myObject);
}
function displayDude(dude) {
//$ is cool isn’t it var divDude = $(“dudeid”); divDude.innerHtml = « » ; //each comes from prototypes too dude.besoin.each(function(d){ divDude.innerHtml += d.name})
}
Here you go, now you have made your first AJAX-JSON web application.
Next.
I'm gonna try to stay focus on what's new with web programming, and show it to you.