Sigma Php Ajax framework, Ajax Components, GUI Builder
May 23, 2012, 07:41:46 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Tutorial 2 - Make An Asynchronous Calling  (Read 8279 times)
steven
Moderator
Hero Member
*****
Posts: 544



View Profile
« on: January 21, 2009, 07:11:09 PM »

What is AJAX?
AJAX = Asynchronous JavaScript and XML
In this tutorial, we will make an application for asynchronous calling.
The simplest way for  asynchronous calling in Sigma Visual is to use function linb.request. Its definition can be found at http://www.sigmawidgets.com/products/sigma_visual/API/index.html#linb.request.
It's declared like the following line.

It's a little complex because it takes 6 parameters. Don't worry about that. For simple code, the first three parameters are enough.
  • uri: The URL of the request target. For example, "http://www.google.com/".
  • query: This is web request parameters pairs. For example, "{para1:1,para2:2}".That will get the same result as we input http://www.google.com/?para1=1&para2=2 in the browser.
  • onSuccess: A function to be executed whenever a request is done successfully. I will explain this function later. But now let's make an application first.

[Req Spec]
1. A dialog window and a button are needed.
2. When end user clicks button, content of another html file will be retrieved and put into dialog window.

[Do It Yourself]
1. Drag a [Dialog] to design area,set its alias to "dialog1"(Click dialog window to select it, type "dialog1" in [Component Config Window]->[alias],and strike [Enter] on keyboard. )
2. Drag a [Button] to design area.
3. Prepare a file named hello.html to http://localhost/hello.html. It reads

4. Add event handler for button being clicking. (Click button to select it,click on right side of [Component Config Window]->[events]->[onClick],a small button will appear. Click this button, a dialog box will pop up.)
5. You will see the following lines in the dialog

6. In the handler, we will call linb.request. Let's have a look of code snippet.


The first parameter, "http://localhost/hello.html", is what we will get synchronously.
The second parameter, the url parameters pairs, is set to null because hello.html is a static html file, not a php file or something else.
The third parameter is function, which will change inner html of dialog1 by calling setHtml(). Variable rep is the result of asynchronous calling to hello.html.

7. Something interesting is that we store variable this to a variable, me. It is a must because variable this in Javascript is quite different from the one in c++/java. You could get more knowledge by search "this in javascript" in google.The whole code looks like


8. Click [OK] to close dialog.
9. Press [run] to see the result.
« Last Edit: February 02, 2009, 04:23:27 PM by steven » Logged

Sigma AJAX Data Grid - Easy to Integrate with PHP, ASP Classic, ASP.NET & Java
Sigma PHP Ajax Framework - WYSIWYG GUI Builder With Tree, Grid, Treegrid, Dialog, Tab & More Component
Lando
Newbie
*
Posts: 3


www.sigma.xq.com.br


View Profile WWW
« Reply #1 on: February 20, 2009, 08:30:14 PM »

Translation to portugues brazilian:

Translation 2
« Last Edit: February 20, 2009, 08:31:55 PM by Lando » Logged

will
Newbie
*
Posts: 2


View Profile
« Reply #2 on: August 27, 2009, 01:19:22 PM »

How would I go about using settimeout() to periodically fire off the ajax request every 30 seconds or so?  I've looked through the docs and can't seem to find anything relevant.


thanks,
Will
Logged
linb
Administrator
Hero Member
*****
Posts: 435


View Profile
« Reply #3 on: August 30, 2009, 09:00:16 AM »

Why don't you use setInterval?
Or use linb.Thread in jsLinb.

If you use 2.2 version in svn:


Or, in the previous version :
Logged
will
Newbie
*
Posts: 2


View Profile
« Reply #4 on: September 15, 2009, 07:45:27 AM »

I'm using 2.1 still, but am a complete noob.  How would I plug that snippet into the tutorial example?  I've been playing with it for awhile but haven't figured it out.


thanks,
Will
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!