greasemonkey ajax发送和接收数据

时间:2016-09-30 20:53:53

标签: javascript ajax greasemonkey

有谁能告诉我如何通过greasemonkey发送json代码?

以下是我的代码网站如何发送数据:     Koepsell

function generate_otp(filerfno_var,passport_no_var) {
    $('#error_msg').html('');
    var value1_var=document.getElementsByClassName("app_field")[0].value;
    var value2_var=document.getElementsByClassName("app_field")[1].value;
    if(document.getElementById('generate_otp').checked == true)
        var otp_required_var="generate_otp";
    else if(document.getElementById('have_otp').checked == true)
        var otp_required_var="have_otp";
    else if(document.getElementById('send_alotment_sms').checked == true)
        var otp_required_var="send_alotment_sms";
    var otp_var=document.getElementById("otp").value;
    var captcha_var=document.getElementById("captcha").value;
    //http://localhost:8084/struts_bgd/json/GenerateOtp?filerfno=BGDDV0004116&passport_no=PASS123&value1=TEST&value2=TEST
    $.ajax({
        type: "POST",
        url: "json/GenerateOtp",
        dataType: "json",
        data: {filerfno : filerfno_var,passport_number:passport_no_var,value1:value1_var,value2:value2_var,otp_required:otp_required_var,otp:otp_var,captcha:captcha_var},
        success: function (data) {
            //alert(data['sms_output']);                    
            alert(data);
            $('#generate_otp_msg').text(data);
            refreshCaptcha();
            $('#captcha').val('');
            $('#have_otp').prop('checked', false);  
            $('#generate_otp').prop('checked', false);  
            $('#send_alotment_sms').prop('checked', false);  
        }
    })
    .done(function (data) {
    })
    .fail(function () {
        alert("Some problem occurred");
    })
    .always(function () {
    });
}

0 个答案:

没有答案