---
title: "API for Development"
url: "https://maker.wiznet.io/forum/11899"
markdown_url: "https://maker.wiznet.io/forum/11899/md"
type: "Forum topic"
category: "General"
author: "blahblah"
created: "2016-08-19T18:10:03+09:00"
last_activity: "2017-05-04T08:39:02+09:00"
language: "en"
views: 1247
replies: 4
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# API for Development

## Question

Asked by blahblah on 2016-08-19 in General.

Hello,

Do you have any information on how the AJAX and Wiz550Web interact? I am using your demo pages and editing them but trial and error is a slow proccess. I was hoping that you had some documentation that explains the the interaction.

Thanks!

## Replies

### Reply 1 by Edward, 2016-08-22

Hi.

Sorry… We not have AJAX information documents…

Web have just simple documents.

refer to below URL. It is simple document. (web page)

[wizwiki.net/wiki/doku.php?id=pro … 0webgsg_en](http://wizwiki.net/wiki/doku.php?id=products:wiz550web:wiz550webgsg_en)

And refer to below URL. It is web page download URL.

[github.com/Wiznet/WIZ550web](https://github.com/Wiznet/WIZ550web)

Thank you

### Reply 2 by blahblah, 2016-08-24

Hi,

Thanks for your reply. Since there is no information on how your application works, I was hoping that you could answer a few questions for me?

1. I am having trouble doing things sequentially and I think it is due to timing. When I execute the code pasted below, not all of the I/O change as expected, and I get a debug error in my browser (Chrome) console that says:

(index):265 POST [192.168.11.100/dout.cgi](http://192.168.11.100/dout.cgi) net::ERR_CONNECTION_REFUSED
AJAX.doPost @ (index):265
(anonymous function) @ (index):390

I was also wondering how I can check the state of a pin, whether or not is is Hi or low?

Thanks!

function postdataPinState(pinNumber,pinState){
var p=pinNumber;
var v = pinState;
dout_timer=setTimeout(function(){
if(dout && dout.abort){dout.abort();}
dout=new AJAX(‘dout.cgi’,function(t){
try{eval(t);}catch(e){alert(e);}
});
dout.doPost(‘pin=’+p+‘&val=’+v);
},300);
}

function postdataPinDir(pinNumber,pinDirection){
var p=pinNumber;
var v = pinDirection;
dout_timer=setTimeout(function(){
if(dout && dout.abort){dout.abort();}
dout=new AJAX(‘dir_change.cgi’,function(t){
try{eval(t);}catch(e){alert(e);console.log(t);}
});
dout.doPost(‘pin=’+p+‘&dir=’+v);
},300);
}

function myDelay(myDelayTime){

for(var i=0; i&lt;myDelayTime;){
i++;
}
}

function setAddrToVersion(){

```
postdataPinState(10,0);
postdataPinState(11,0);
postdataPinState(12,0);
postdataPinState(13,0);
```

}

function setDataBusToInput(){

```
postdataPinDir(0,1);
myDelay(1000);
    postdataPinDir(1,1);
myDelay(1000);
postdataPinDir(2,1);
myDelay(1000);
    postdataPinDir(3,1);
myDelay(1000);
postdataPinDir(4,1);
myDelay(1000);
postdataPinDir(5,1);
myDelay(1000);
postdataPinDir(6,1);
myDelay(1000);
postdataPinDir(7,1);
```

}
function setDataBusToOutput(){

```
postdataPinDir(0,2);
myDelay(1000);
    postdataPinDir(1,2);
myDelay(1000);
postdataPinDir(2,2);
myDelay(1000);
    postdataPinDir(3,2);
myDelay(1000);
postdataPinDir(4,2);
myDelay(1000);
postdataPinDir(5,2);
myDelay(1000);
postdataPinDir(6,2);
myDelay(1000);
postdataPinDir(7,2);
```

}

function getRevisionNum(){

```
setTimeout(setDataBusToInput(),1500*1);

setAddrToVersion();

//setDataBusToOutput();
```

}

### Reply 3 by blahblah, 2016-08-25

Hi,

I would also like to know how to read the status of an actual pin without having to check the html alias/name.

Thanks!

### Reply 4 by blahblah, 2016-09-06

Nevermind… as if you were actually working on it.

There are two ways to do what I wanted.

1. use JQuery and the when() then() methods

2. simply make ajax synchronus (this is what I used)

function AJAX(url, callback)
{
var req = AJAX_init();
req.onreadystatechange = AJAX_processRequest;

```
 function AJAX_init() { 
	 if (window.XMLHttpRequest) { 
	 	return new XMLHttpRequest(); 
	 } else if (window.ActiveXObject) { 
	 	return new ActiveXObject('Microsoft.XMLHTTP'); 
	 } 
 };
  
 function AJAX_processRequest() { 
	 if(req.readyState == 4) { 
	 	if(req.status == 200) { 
	 	if(callback) 
	 		callback(req.responseText); 
	 	} 
	 } 
 }; 
 
 this.doGet = function() { 
	 req.open('GET', url, false); // set this to false for synchronous behavior
	 req.send(null); 
 };
  
 this.doPost = function(body) { 
	 req.open('POST', url, false); // set this to false for synchronous behavior
	 req.setRequestHeader('Content-Type', 
	 'application/x-www-form-urlencoded'); 
	 req.setRequestHeader('ISAJAX','yes'); 
	 req.send(body); 
 };
```

};

---

Source: https://maker.wiznet.io/forum/11899
