Ajax有时不工作

时间:2017-04-18 21:42:48

标签: ajax

下面是ajax代码。它有时适用于铬,有时它不起作用。有什么想法吗?

$.ajax({
    type: "POST", 
    //prod 
    url: "b2c_process_function.php",
    data: dataString,
    timeout: 4000,
    complete: function() {
        number = (Math.random() + ' ').substring(2,10) + (Math.random() + ' ').substring(2,10);
        window.location.href = 'thankyou.php?OID=' + number + '&from=home'; 
    }
});

1 个答案:

答案 0 :(得分:0)

Chnage data: dataString,data: {dataString:dataString}如下:

var dataString = 'test'; // or as you like

 $.ajax({
    method: "POST", 
    //prod 
    url: "b2c_process_function.php",
    data: {dataString:dataString},
    timeout: 4000,
    complete: function(data) { //success
        alert(data)
        number = (Math.random() + ' ').substring(2,10) + (Math.random() + ' ').substring(2,10);
        window.location.href = 'thankyou.php?OID=' + number + '&from=home'; 
    }
 });