External js function is not accessible

I am trying to access an external js function as follows, but it is not working.
I used “untyped” to get past the compiler errors.
Using Haxe 4 , updated in last 15 days.

index.html

   function sendToDb(pData){
  		$.post("http://localhost/binsort/insertData.php", pData);
  	}

Haxe

static public function addUserToWinList():Void 
	{
			 var data = {
            username: username_Str,
            won: 0 
        };

		
		untyped Browser.window.document.sendToDb(data);
	
	}

Hi Vishwas,
Looks like you need to write an extern to call that function.



I hope that helps.

Here is another tutorial which might be closer to what you need.
http://old.haxe.org/doc/js/extern_libraries

1 Like

Ok that works. Thanks.

However I noticed that for some reason the extern class must be outside of the app’s package. It does not work if I use it inside the app’s main package.