This site uses tracking cookies. By using this site, you agree to our Privacy Policy. If you don't opt in, some parts of the site might not function.
Blog
Home / Blog / FileMaker / FileMaker and Javascript: AJAX POST
17Nov 2014

FileMaker and Javascript: AJAX POST

About the Author

Mike Duncan Mike Duncan

Mike is an AWS Certified Solutions Architect as well as a certified FileMaker Developer. In addition to his work, Mike also enjoys pursuing his art, freelance writing, traveling, and spending time with his family.

Comments (16)

Fabio Bosisio - January 13, 2015

Nice post, Mike. Very useful!
Thank you for sharing.

Reply
Eamon - November 2, 2015

Great tutorial and it worked first time on my Mac.
However I could not get it to work on Filemaker Go V13 and V14 on my iPad 9.1(13B143)

Reply
Mike Chapman - April 26, 2016

Hi Mike,
I cant download the sample file, could you help please

Reply
Anthony Courchesne - July 8, 2016

Nice tool !
Is there a way to use it to POST an XML request to my Web Service so it can execute a function and return the result to Filemaker ?

I tried but don’t get any response from the web service…

Reply
    Mike Duncan
    Mike Duncan - July 8, 2016

    Hi Anthony,

    I guess that depends on your web service. If it is something you developed, you can have it do whatever you like. Otherwise, you may be constrained to the functionality of that particular service. If you do not get a response, it’s likely a CORS issue.

    Mike

    Anthony Courchesne - July 8, 2016

    Hi Mike,

    Yes, it is a web service that I developed and will always be at localhost. If its a CORS issue, does that mean that I have no way of making it work with the FileMaker WebViewer ?

    Thanks,
    Anthony

      Mike Duncan
      Mike Duncan - July 8, 2016

      At the end of the blog post, I show an example of the settings to enable CORS access in PHP by setting the needed http headers. Do those help?

Jeff Almquist - August 17, 2016

Hi Mike. Thank you so much for this technique. It works great in FileMaker Pro. But it’s not working in Web Direct. Can you think of why that might be?

Reply
    Mike Duncan
    Mike Duncan - August 19, 2016

    Hi Jeff,

    This will only work in Pro and Go as it is written, since it depends on the FMP URL to get the data returned to the client. You could always use a little CWP to pass the result back to the server and get it working with WebDirect as well.

    Mike

Mathijs van Beurden - September 22, 2016

Hi Mike,

Great post!

I am looking into creating a standalone FileMaker Go 15 solution that can post some data to a local web service ( JSON data with custom headers ). The Webservice is out POS system.

Because i have no Filemaker Server or even Pro on premise I cannot use plugins like MBS or BaseElements.

This post seemed to be Just what I needed to continue with this product. BUT, unfortunately I am running blancs here. This sollution works perfect on FileMaker Go 14, but not on FileMaker Go 15.

I Believe it’s due to this : LINK : http://help.filemaker.com/app/answers/detail/a_id/15999

on the bottom:
“If the web viewer has embedded HTML that includes file references, the web viewer will appear to be empty in FileMaker Go 15. Instead, create an HTML file and save it along with any related files in the Temporary folder. Then, change the web viewer to reference the HTML file.”

So i Adapted you file a little to play around with it.

Set Variable [ $HTMLFile; Value: Get ( TemporaryPath ) & “PostField.html” ]
Set Variable [ $output; Value: “file:” & $HTMLFile ]
Export Field Contents [ Requests::post field; “$output” ]
Set Web Viewer [ Object Name: “Web” ; URL: $output” ]

I can find the file in my TemporaryPath and open it with Chrome or Safari, and the post is sent, but for some reason the post is not send by the WebViewer.

No idea what i am doing wrong here…

Reply
    Mike Duncan
    Mike Duncan - September 23, 2016

    There are no assets saved outside of the file, so that kb article doesn’t apply. I am able to replicate the error, which seems to have to do with FM 15 and possibly iOS 10 safari handling minified data url with javascript. I will try to find time to update it.

    In the meantime, you can always write a fairly simple PHP script that could take your request and relay to the final endpoint. That php script can be made more friendly to the FM insert from URL script, so could still work from Go with supported script steps. Would that work in the interim at least?

Mathijs van Beurden - September 26, 2016

Hi Mike, a PHP script would probably be great also, but i have no knowledge of php or javascript at that. i must say that the javascript you provided is fairly simple to read…

Reply
Ricardo Devoto - October 7, 2017

Hi Mike, thanks so much for the demo: it works perfectly using POST method but not with GET and I don’t understand why.

Reply
    Mike Duncan
    Mike Duncan - October 10, 2017

    I believe if you are using GET, you can just use the insert from URL script step, right?

Leave a Reply