paypal_lib 表单在 codeigniter 中不工作
paypal_lib form not working in codeigniter
我已经在我的控制器中加载了 paypal 库并编写了用于 paypal 集成的代码。
class Register extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->library('session');
$this->load->library('email');
$this->load->helper('url');
$this->load->library('paypal_lib');
}
public function signup()
{
$this->paypal_lib->add_field('return', $returnURL);
$this->paypal_lib->add_field('rm','2');
$this->paypal_lib->add_field('cancel_return', $cancelURL);
$this->paypal_lib->add_field('notify_url', $notifyURL);
$this->paypal_lib->add_field('item_number', $pkgid);
$this->paypal_lib->paypal_auto_form();
}
}
在我的模板文件中:
jQuery.ajax({
url : '<?php echo $base_url; ?>register/signup',
type: 'POST',
data: jQuery(form).serialize(),
success:function(response){
console.log(response);
}
});
我无法移动到贝宝网站商店。仍然在同一页面上,没有任何重定向。如何解决这个问题?
你什么都不return。将函数“signup”更改为:
class Register extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->library('session');
$this->load->library('email');
$this->load->helper('url');
$this->load->library('paypal_lib');
}
public function signup()
{
$this->paypal_lib->add_field('return', $returnURL);
$this->paypal_lib->add_field('rm','2');
$this->paypal_lib->add_field('cancel_return', $cancelURL);
$this->paypal_lib->add_field('notify_url', $notifyURL);
$this->paypal_lib->add_field('item_number', $pkgid);
echo json_encode($this->paypal_lib->paypal_auto_form(), JSON_UNESCAPED_UNICODE);
}
}
最好在您的 JS 代码中将您的数据类型更改为 JSON:
jQuery.ajax({
url : '<?php echo base_url(); ?>index.php/register/signup',
type: 'POST',
dataType: "JSON",
data: jQuery(form).serialize(),
success:function(response){
console.log(response);
}
});
最后我分析了这个问题。我们不应该在 ajax 上使用 paypal_lib。因为 codeigniter 忽略了 ajax 上的重定向概念。
我已经在我的控制器中加载了 paypal 库并编写了用于 paypal 集成的代码。
class Register extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->library('session');
$this->load->library('email');
$this->load->helper('url');
$this->load->library('paypal_lib');
}
public function signup()
{
$this->paypal_lib->add_field('return', $returnURL);
$this->paypal_lib->add_field('rm','2');
$this->paypal_lib->add_field('cancel_return', $cancelURL);
$this->paypal_lib->add_field('notify_url', $notifyURL);
$this->paypal_lib->add_field('item_number', $pkgid);
$this->paypal_lib->paypal_auto_form();
}
}
在我的模板文件中:
jQuery.ajax({
url : '<?php echo $base_url; ?>register/signup',
type: 'POST',
data: jQuery(form).serialize(),
success:function(response){
console.log(response);
}
});
我无法移动到贝宝网站商店。仍然在同一页面上,没有任何重定向。如何解决这个问题?
你什么都不return。将函数“signup”更改为:
class Register extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->library('session');
$this->load->library('email');
$this->load->helper('url');
$this->load->library('paypal_lib');
}
public function signup()
{
$this->paypal_lib->add_field('return', $returnURL);
$this->paypal_lib->add_field('rm','2');
$this->paypal_lib->add_field('cancel_return', $cancelURL);
$this->paypal_lib->add_field('notify_url', $notifyURL);
$this->paypal_lib->add_field('item_number', $pkgid);
echo json_encode($this->paypal_lib->paypal_auto_form(), JSON_UNESCAPED_UNICODE);
}
}
最好在您的 JS 代码中将您的数据类型更改为 JSON:
jQuery.ajax({
url : '<?php echo base_url(); ?>index.php/register/signup',
type: 'POST',
dataType: "JSON",
data: jQuery(form).serialize(),
success:function(response){
console.log(response);
}
});
最后我分析了这个问题。我们不应该在 ajax 上使用 paypal_lib。因为 codeigniter 忽略了 ajax 上的重定向概念。