XMLHttpRequest

Community Forums/Monkey Talk/XMLHttpRequest

Nigel Brown(Posted 2013) [#1]
I am evaluating Monkey before purchasing and have not been able to find anything that will allow me to "POST" successfuly.

I have tried the minimal examples based around the utils module and although this seems to pass the request to the server (the server ses it) it never picks up any response?

Strict

Import mojo
Import utils

Class myApp Extends App

	Field http:XMLHttpRequest
	Field response:String

	Method OnCreate:Int()
		response = ""
		http = New XMLHttpRequest()
		http.open( "http://myurl", "POST" )
		http.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" )
		http.send("temperature?")
		SetUpdateRate(30)
		Return 0
	End

	Method OnUpdate:Int()
		response = http.responseText
		Return 0
	End

	Method OnRender:Int()
		Cls
		DrawText( "reply = " + 	response, 10, 10 )
		Return 0
	End
End

Function Main:Int()
	New myApp
	Return 0
End