weixin_33709219 2015-10-11 00:22 采纳率: 0%
浏览 25

Ajax帖子和代码点火器

I need to send 2 values to my codeigniter controller complete the request. But I failed in all attempts.

My Controller need to receive:

$token = $this->input->post('cc_token');
$hash = $this->input->post('sender_hash');

Ajax

$(document).ready(function ({
    var sender_hash = myfunction.getSenderHash();

    var card_token = myFunction.createCardToken({
        cardNumber: "4111111111111111",
        brand: 'visa',
        cvv: "123",
        expirationMonth: "12",
        expirationYear: "2030",
        success: function (response) {

        },
        error: function (response) {
            console.log(response);
        }
    });
    $("#submit").click(function () {

        $.ajax({
            url: '<?php echo $details->id?>',
            type: 'POST',
            data: 'cc_token=' + card_token + '&sender_hash=' + sender_hash,
            beforeSend: function () {
                console.log("Your request is being processed. Wait...");
            },
            success: function (data) {
                console.log("Thank you for donating. Your request has been successfully processed!");
            },
            error: function (data) {
                console.log("There was an error sending the data. Try again.")
            }

        });
    });
});

But the post was not send to controller. What i'm doing wrong? If i put these values in input, works fine, but I don't wanna to do that, because this is not the right way.

  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 c++字符串分割问题
      • ¥15 关于#sql#的问题:没有用命令关闭cdc,手动把系统表开启的cdc右键删除了
      • ¥15 android freedom
      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题
      • ¥15 win11如何运行geoserver
      • ¥15 审稿意见请教-用ERNIE进行小样本分类的对比实验问题
      • ¥15 gem5搭建arm v8