ajax post 跨域访问

前端之家收集整理的这篇文章主要介绍了ajax post 跨域访问前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
 
PHP
header('Access-Control-Allow-Origin:*'); header('Access-Control-Allow-Methods:POST,GET'); header('Access-Control-Allow-Credentials:true'); 
js:
$.ajax({ type: 'POST', url'https://to.com/postHere.PHP' crossDomain true data'{"some":"json"}' dataType'json' successfunction(responseData textStatus jqXHR) {var value = responseDatasomeKey;},0)"> errorfunction errorThrown alert('POST Failed.');}});
原文链接:https://www.f2er.com/ajax/163007.html

猜你在找的Ajax相关文章