English 中文(简体)
我如何通过日本宇宙航空研究开发机构向脑树转变方向提交表格数据?
原标题:How do I submit form data via AJAX to Braintree Transparent redirect?

这里使用Adhur和JQuery。

我们以前使用正常的<代码>form.submit()提交审定(JQuery plugin)电话的submitHandler。 这已提交“脑树”具有透明度的后向旋转方向,而后向方向则是我们的服务器上的GET手。 我们这样做是肯定的,然后是对我们手里的又一个方向。 如果所提交的数据确实通过大脑(坏信用卡,即),那么我们就把约html写到“<div id=“error”>errormessage</div> in the response from thishandler,并插入用户页。

The problem is if there is an error in our handler, which would produce a 500 status code, everything falls to hell and the user s page has undesirable behavior.

如果发生这种情况,我想能够处理我的手里的500份答复。

我认为,我可以采用<代码>statusCode,称号为j Query s AJAX。

在座各位(在<条码>提交书Handler):

var data = $(form).serialize();
$.ajax({
  type:  POST ,
  url: braintree_url,
  data: data,
  statusCode: {
    500: function() {
      alert( broked response yo );
    }
  }
});

然后,我故意在我们手里造成错误,迫使500人。

但是,我向“脑树陶”屈指的神.不行。 但form.submit(>);则实行罚款。

我做了什么错误? 我错误地认为,可以像现在这样通过非洲复兴开发银行提交表格,并产生同样的结果?

妇联正在向我们的html表提供一些属性,具体如下:

%form#addcard{"action": braintree_url, "method": "post", "autocomplete": "off", "submittype": "secure", "next": braintree_url, "target": "hidden_iframe")}

EDIT:

我在更多地阅读了麻风病后认识到,我在这里提出的可能原因并不是因为有人违反同一来源政策而向另一个领域(巴林)发出呼吁。 因此,浏览器没有执行。

from: http://api.jquery.com/jQuery.ajax/

由于浏览器安全限制,大多数“Ajax”申请都受到同一来源政策的制约;请求无法从不同领域、次域或议定书成功地检索数据。

问题回答

Ok... 这是十年之久的麻风病,但为我做了大量工作:

Use a normal form submission (no calls to $.ajax), but target a hidden iframe in your page:

<form action="<%= Braintree::TransparentRedirect.url %>" method="POST" target="braintree-result">
...
</form>

<iframe name="braintree-result" id="braintree-target" style="display:none;"></iframe>

然后对iframe sload进行跟踪。 活动:

$( #braintree-target ).on( load , function() {
    var data = $.parseJSON( $(this).contents().text() );
    // Handle response data here
});

然后改变你的脑树呼号,以归还JSON数据,从而使你能够处理客户。 !! 请注意,这种方法假设你重新把脑树重新引向与本页相同的URL。 否则,我就不认为你能够读到字面内容。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签