0

Magento で PHP Web サービスへの 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 に変更すると機能します。

前もって感謝します。

4

1 に答える 1

0

ねえ、これがあなたがすべきことです。

ID を送信するために必要な値をフォームに指定します。例:

<form id ="myfrom" >

ajax呼び出しで、代わりに次のようにします

data: dataString,

行う

data : $('#myform').serialize() ,

それが修正されるかどうか教えてください。PHP の部分では、最初に行うことをお勧めします

print_r($_POST);

データがどのように渡されるかを確認するためです。

于 2012-11-19T12:08:18.347 に答える