You need to sign in to do that
Don't have an account?
Chris Davidson 4
Pardot Form Handler and Ajax
Hi all,
I am currently working on a project that involves a Form Handler that uses Ajax to perform a calculation. In the past month the form itself has had 189 succesful submissions. However the number of unsuccessful submissions is much higher. While the Ajax is handling the calculation and serving the results to the client, Pardot receives the post so infrequently that it is becoming difficult to attribute a cause.
The developer I am working with came across this today.
"Pardot doesn't support submitting data to form handlers via Ajax requests. When attempting to submit data to a form handler using Ajax, you will likely see errors like:
XMLHttpRequest cannot load {www.site.com/FormHandlerURL}. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '{page from which form handler should be getting submitted on client's website}' is therefore not allowed access.
This is what's known as CORS (Cross-Origin Resource Sharing). Pardot doesn't currently support CORS or JSONP for form handlers. It is possible to simulate a JSONP response by setting the Success and Error URLs for the form handler to be JavaScript URLs that execute Success and Error callbacks, respectively."
Can anyone point me in the direction of documentation that can support this claim or attest to it being valid? I believe that we have a solution however I am trying to understand the reasoning why they would not support this.
Thank You in Advance
I am currently working on a project that involves a Form Handler that uses Ajax to perform a calculation. In the past month the form itself has had 189 succesful submissions. However the number of unsuccessful submissions is much higher. While the Ajax is handling the calculation and serving the results to the client, Pardot receives the post so infrequently that it is becoming difficult to attribute a cause.
The developer I am working with came across this today.
"Pardot doesn't support submitting data to form handlers via Ajax requests. When attempting to submit data to a form handler using Ajax, you will likely see errors like:
XMLHttpRequest cannot load {www.site.com/FormHandlerURL}. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '{page from which form handler should be getting submitted on client's website}' is therefore not allowed access.
This is what's known as CORS (Cross-Origin Resource Sharing). Pardot doesn't currently support CORS or JSONP for form handlers. It is possible to simulate a JSONP response by setting the Success and Error URLs for the form handler to be JavaScript URLs that execute Success and Error callbacks, respectively."
Can anyone point me in the direction of documentation that can support this claim or attest to it being valid? I believe that we have a solution however I am trying to understand the reasoning why they would not support this.
Thank You in Advance
I'm going through the same thing right now. I was able to find this Stack Overflow question: https://stackoverflow.com/questions/47047487/simulate-a-jsonp-response-with-javascript-urls that got me most of the way. My form is now submitting to Pardot using JSONP, the issue I'm still fighting is the success and error responses back to the form after submission. I've set up two pages, but apparently my JSON response on those pages isn't correct or isn't working.
Did you get anywhere with it?
Thanks,
Sam
$.ajax({
type: 'POST',
url: '',
data: dataString,
dataType: 'jsonp',
})
Refused to execute script from " "new console error : because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.