将js函数转换为jquery函数

时间:2017-09-11 15:34:16

标签: javascript jquery ajax

我有以下javascript函数,我想转换为Jquery:

function confirm() {

    var http = new XMLHttpRequest();
    var url = "index.php?tag=' . $dt . '";
    var params = "confirm_ref=' . urlencode(encrypt($br,$k)) . '";
    http.open("POST", url, true);
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.onreadystatechange = function() {
            if(http.readyState == 4 && http.status == 200) {

            }
                }
    http.send(params);
    }

有关如何正确设置的任何指示? 感谢。

1 个答案:

答案 0 :(得分:0)

Jquery有一个可以使用的库来发送Ajax请求。

这是一个工作样本 - https://www.formget.com/submit-form-using-ajax-php-and-jquery/