webpage communication

Go To Last Post
2 posts / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello guys, 


I have a serious problem that I have dealing for couple of days. I need to transfer a integer value from a webpage that I'm running on mu SAM4E-Ek to do certain tasks. I'm not sure if here is the write place to ask, I hope u can give me some hints. I'm using JSON suportign AJAX and identifing the nae in cgi.c library. The problem is that I don't read any single value I have achieved to send data over the Ethernet cable to update the webpage but the reverse method is a bit confusing to me.

var i;

function buttonClick(){
			document.getElementById('inc').value = i++;
					url: "get_increment",
					async: false,
					cache: false,
					dataType :'json',
					success: function(){

That is the JS code where I'm increment a value with a button in the webpage.


static int cgi_increment(const char *name, char *recv_buf, size_t recv_len );

{CGI_MATCH_NAME, "get_increment", cgi_increment},	

static int cgi_increment(const char *name, char *recv_buf, size_t recv_len)

	char *query_str = strstr(name, "?") + 1;
	size_t query_str_len = strlen(query_str);

	http_tokenizeGetRequest(query_str, query_str_len);

	if (http_getValue(query_str, query_str_len, CGI_INCREMENT_DECREMENT, key_value,
	sizeof(key_value)) < 0) {
		goto error;

	swit = atoi(key_value);
	//ili93xx_draw_string(92, 151, (uint8_t *) key_value);

	sprintf((char *)tx_buf, "{\"dai\":%i,}", swit);

	http_write((const char *)tx_buf, strlen((char *)tx_buf));
	return 0;

	//	swit = key_value;
		return 0;


And here in the cgi.c I'm trying to read the values and use the value elsewhere in the code but unfortunately I'm wrong somewhere and I'have no idea where the problem is.


Thank you in Advace    

Last Edited: Fri. Mar 11, 2016 - 12:50 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

JSON requires " not '
But that is probably not your issue. I got bit by that yesterday.

So which end is the problem? I normally use Chrome as it has extensive debugging. You can quickly determine if the browser side is sending the correct data. On the server side, are you getting as far as trapping the cgi request? You should be able to use the debugger to step through the code and see where things go wrong.