本文介绍了使用JavaScript URL模拟JSONP响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在WP网站上使用重力形式.我的表单通过ajax使用Pardot 表单处理程序.我遇到一个问题,Pardot处理6x表单,没有其他错误.研究表明,这是因为Pardot不支持CORS或JSONP,因此在使用ajax提交时陷入了循环.当表单处理程序的成功URL设置为引用URL时,它正在处理提交,但从不完成".它会在放弃之前尝试使用6倍,每次处理提交的数据并发送新的潜在客户通知电子邮件.

I'm using Gravity Forms on a WP site. My forms POST via ajax to Pardot using Pardot form handlers. I am running into an issue where Pardot processes the form 6x, with no other errors. Research indicates that this is because Pardot does not support CORS or JSONP, and thus gets stuck in a loop when using ajax to submit. It's processing the submission but never "finishing" when the form handler's Success URL is set as referring URL. It tries 6x before giving up, processing the submitted data and sending new prospect notification emails each time.

Pardot 帮助文档建议以下解决方案:

Pardot help docs suggest the following solution:

我不确定这意味着什么或如何实现.我已经做了一些stackoverflowing和谷歌搜索,但我似乎无法全神贯注于如何做到这一点.有人可以帮助您澄清这个概念或为我指明正确的方向吗?

I'm not totally sure what this means or how to approach it. I've done some stackoverflowing and googling, but I can't seem to wrap my head around how to do it. Can someone help clarify this concept or point me in the right direction?

谢谢!

推荐答案

Pardot的建议是在您自己的服务器上创建2个静态URL,这些URL返回简单的JSON响应.

What Pardot is suggesting is to create 2 static URLs on your own server that return a simple JSON response.

例如:

  1. mysite.com/pardot-success

返回:{"result":"success"}

  1. mysite.com/pardot-error

返回:{"result":"error"}

然后,您将使用这两个URL作为Pardot表单处理程序设置的成功和错误重定向URL.

You'll then use those two URLs as your success and error redirect URLs for your Pardot form handler settings.

然后可以使用JSONP向您的Pardot表单处理程序发出AJAX请求,该请求将包装并返回其中一个URL的JSON响应(取决于结果).

An AJAX request can then be made to your Pardot form handler using JSONP, which will wrap and return the JSON response from one of those URLs (depending on the result).

您的AJAX响应数据将包含您的JSON结果(成功或错误).

Your AJAX response data would include your JSON result (success or error).

这篇关于使用JavaScript URL模拟JSONP响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 04:53