简体   繁体   中英

AJAX Post Request not working in Safari

I have a tag in my jsp as follows:

<a href="<%=rest.getString(5)%>" onclick="javascript: generateLog(<%=id%>,<%=id2%>,<%=id3%>);">xxxx</a>

The function generateLog is defined as follows:

function generateLog(id1,id2,id3) {
        $.ajax({
           type: "POST",
           url: "generateLog.jsp",
           data: "id1=" + id1+"&id2="+id2+"&id3="+id3,
           cache: false,
           async: true
         });

}

In the generateLog.jsp, code is written to insert the click ids into a table. It works fine in IE, Mozilla Firefox and Google Chrome but does not work in Apple Safari.

It seems the page navigates to href page location before the post request is completed. How can I make it work in Safari? Please help.

使async : !$.browser.safari

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM