Javascript/Jquery Post and Get?
Javascript/Jquery Post and Get?
是否有可能有一段代码或函数执行以下操作。
我想让一个 javascript 文件使用变量向我的不同域发送请求。此网页将根据数据库检查变量,并将 TRUE 或 FALSE 的结果返回到原始 JavaScript 文件
如果要在域之间发送请求,则应查看dataType
设置为jsonp
http://api.jquery.com/jQuery.ajax/,以使用脚本标记加载响应。
有关 JSONP 的更多详细信息:https://stackoverflow.com/search?q=jsonp
我不知道JSONP并使用了不同的方法
$.ajax({
type: "GET",
crossDomain:true,
url: 'http://otherdomain/check.php',
success: function(data) {
// check.php response
}
});
并检查.php
<?php
$allowable_hosts = array('http://originaldomain','http://anotherdomain');
if (in_array($_SERVER['HTTP_ORIGIN'],$allowable_hosts))
header('Access-Control-Allow-Origin: *');
//echo "ok"; - your check code
?>
相关文章:
- How can I get and replace this in javascript ( jquery?
- Javascript change window.location and run async ajax get
- app.get and app.post get value in node.js
- Javascript/Jquery Post and Get?
- Meteor session.set/get and jquery modal
- Merging $.get and $.ready
- Get and javascript? like php's if $_GET[foo]
- new Parse.View and get"TypeError:undefined不是函数;
- 如何将post-and-get方法与jquery相结合
- onclick and get in jquery
- JQuery get formaction and formmethod
- URLs loop and jquery.get()
- 如何在 app.get() 中$and将值从 getCondition 返回到 options.where
- Ajax get and NodeJS?
- Javascript HTTP GET and POST
- AngularJS get and set value
- Prevent javascript GET and Script
- jquery.get and servlet
- Meteor Session.get and Regex
- http.get and node.js and JSON