简体   繁体   中英

how to send a http request in the background in javascript?

I have a button, the event would be onclick and then the javascript function will send to server the request(for example a rating button on an item), the page should not be redirected, basically I want the event to happen in the background. How to do that? Please give me some idea or code.

Welcome to the marvelous world of AJAX. One of the issues with ajax calls is that different browsers have different implementations of ajax. It's better if you can use a javascript library that abstracts these differences. I'd suggest you to pick up jQuery. You can make ajax calls in jQuery using $.get() , $.post() or $.ajax()

看看jQuery.ajax

you can use jquery ajax to achieve your goal. Its quite simple :)

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