我正在尝试在 Magento 中对 PHP 网络服务进行 AJAX 调用。这是我的 PHP 代码片段。
<?php
$callbackUrl = "http://localhost/magento/webservices/NewCustomer1.php";
//intiate oauth callback URL
$temporaryCredentialsRequestUrl = "http://localhost/magento/oauth/initiate?oauth_callback=". urlencode($callbackUrl);
$adminAuthorizationUrl = 'http://localhost/magento/admin/oauth_authorize';
$accessTokenRequestUrl = 'http://localhost/magento/oauth/token';
//Magento rest API URL
$apiUrl = 'http://localhost/magento/api/rest';
//Consumer key and secret
$consumerKey = 's3xt7w8lwhfrrfzrfvwm3lrilkf66d5n';
$consumerSecret = 'vr3eq1x899pz1cf4zzxjzx3q03t66r3n';
//get customer attributes
$firstname=$_POST['fname'];
$lastname=$_POST['lname'];
$email=$_POST['email'];
.......
这是我的jQuery
$('#btnSubmit').click(function(){
console.log("Submit Clicked");
var fName=$('#firstname').val();
var lName=$('#lastname').val();
var email=$('#email_address').val();
var password=$('#password').val();
var pass_conf=$('#confirmation').val();
var dataString = 'fname='+ fName + '&lname=' + lName + '&email=' + email + '&password=' +password+ '&webid=1&groupid=1';
/*http://localhost/magento/webservices/Newcustomer1.php?fname=siri&lname=s&email=siri@abc.com&password=password123&webid=1&groupid=1*/
//your validation code
$.ajax({
url: 'http://localhost/magento/webservices/Newcustomer1.php',
type: 'POST',
data: dataString,
success: function(data) {
$('#message').html(data);
}
});
});
提交时出现 302 Found 错误。如果我在 URL 本身中传递参数并将 $_REQUEST 更改为 $_GET,它会起作用。
提前致谢。