我有一个表单,将文件中的文件上传到远程服务器.因此,在提交url服务器返回json数据与操作结果,我的iframe捕获.
{'result': 'true' or 'false'}
Run Code Online (Sandbox Code Playgroud)
现在我想将这个json作为我的iframe的回调来检索.我知道我需要jsonp来实现这一点,因为它是一个跨站点调用.这是我的函数,其中包含来自IBM网站的示例代码:
function fileUploadFunction(){
var fileUploadForm = $('#file_upload_form');
fileUploadForm.attr('action', uploadURL);
fileUploadForm.submit();
$('#upload_target').load(function () {
alert("IFrame loaded");
$.getJSON(uploadUrl+"&callback=?", function(data) {
alert("Symbol: " + data.symbol + ", Price: " + data.price);
});
});
};
Run Code Online (Sandbox Code Playgroud)
但这里几乎没有出现问题.首先 - 我的uploadUrl只是"http:// something /".我是否需要它来支持带$callback=后缀的通话?
其次 - 服务器仅在文件上传时给出响应.所以我需要获取存储在我的iframe中的结果,而不是指定的url.怎么解决这个?
这是链接.注意表单中隐藏的iframe.服务器的结果显示在那里.:
http://ntt.vipserv.org/artifact/
编辑
我以前尝试过:
$('#upload_target').load(function () {
var ret = frames['upload_target'].document.getElementsByTagName("body")[0].innerHTML;
var data = eval("("+ret+")");
});
Run Code Online (Sandbox Code Playgroud)
但它引发了"权限被拒绝"的错误.
如何实现一个不会成为我们网站DoS工具的slowban?
问题是服务http响应的故意延迟将使服务器资源忙(Web服务器线程和可能的其他子系统).
是否可以用 Java 或其他语言发出 GET 和 POST 请求,这样您就不必关心返回的内容了?
就像只是发送请求但不想收到任何响应一样?
我按下后退按钮时清除缓存有问题.
我的标题信息是说我从缓存加载:
Status Code:200 OK (from cache)
Run Code Online (Sandbox Code Playgroud)
我的回答是:
$response = new Response;
$response->expire();
$response->headers->addCacheControlDirective('must-revalidate', true);
$response->headers->addCacheControlDirective('allow_reload', true);
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?这些文档方法似乎都不起作用......
我有一个asp .net网页和一个按钮.我在按钮单击事件中调用ajax方法,如下所示
$("#btnTest").click(function () {
$.ajax({
type: 'POST',
url: 'test2.aspx',
success: function (data) {
alert( data);
},
error: function (data) {
alert("In error ");
}
});
});
Run Code Online (Sandbox Code Playgroud)
成功部分警报(数据)我得到页面test2.aspx的html代码(我在ajax url中给出了一个).
在test2.aspx.cs中,代码如下
protected void Page_Load(object sender, EventArgs e)
{
jsonTest();
}
public List<string> jsonTest()
{
List<string> list = new List<string>();
list.Add("aa");
list.Add("bb");
list.Add("cc");
return list;
}
Run Code Online (Sandbox Code Playgroud)
为什么"list"中的这些数据不会作为ajax中的响应数据出现?
我试图将2个控制器结果放在一个控制器中,所以我使用'$response = $this->forward('Bundle:Controller:functionXXX');' 转发第一个控制器.
在控制器' functionXXXAction'我使用renderView返回响应.
问题是转发函数在页面顶部返回此标题:
"HTTP/1.0 200 OK Cache-Control: no-cache Date: Wed, 24 Apr 2013 09:56:50 GMT"
Run Code Online (Sandbox Code Playgroud)
任何解决方案将其隐藏在页面中?!
我尝试发送这两个请求,但我只得到标题中列出的错误作为响应.我对谷歌服务器的两个网络请求是这样的:
HttpClient http = new HttpClient();
HttpResponseMessage response = await http.GetAsync("https://accounts.google.com/o/oauth2/token?code="+localSettings.Values["AccessKey"]+"&client_id=XX-XXXXXXXXXX.apps.googleusercontent.com&client_secret=XXXXX-XXXX&redirect_uri=http://localhost/oauth2callback&grant_type=authorization_code");
//response.EnsureSuccessStatusCode();
Debug.WriteLine(response.ToString());
HttpResponseMessage response1 = await http.GetAsync("https://content.googleapis.com/youtube/v3/subscriptions?part=id&maxResults=10&mine=true&key="+localSettings.Values["AccessKey"]);
Debug.WriteLine(response1.ToString());
Run Code Online (Sandbox Code Playgroud)
我从调试器获得以下输出:
StatusCode: 405, ReasonPhrase: '', Version: 2.0, Content: System.Net.Http.StreamContent, Headers:
{
server: GSE
alt-svc: quic=":443"; p="1"; ma=604800
cache-control: max-age=0, private
accept-ranges: none
date: Tue, 29 Sep 2015 16:05:03 GMT
x-frame-options: SAMEORIGIN
vary: Accept-Encoding
x-content-type-options: nosniff
alternate-protocol: 443:quic,p=1
x-xss-protection: 1; mode=block
content-type: application/json
expires: Tue, 29 Sep 2015 16:05:03 GMT
}
StatusCode: 400, ReasonPhrase: '', Version: 2.0, Content: System.Net.Http.StreamContent, Headers:
{
server: …Run Code Online (Sandbox Code Playgroud)使用Paw,我正在访问用于发出身份验证请求的端点.响应通过JSON返回并包含一个sessionId,我需要将其作为变量(SESSION_ID)放入我的环境中.然后,在发送回服务器的所有请求的Authorization标头中使用此环境变量.
有没有办法从身份验证响应中提取sessionId值的脚本并将值放入环境变量中,而不必每次进行身份验证时都执行复制和粘贴?
感谢您的帮助.
在我的Django项目中,我需要在我的视图中将一些数据发送/发布到第三方URL,并重定向到它提供的网页.例如,我可以简单地做一些事情
class TestView(TemplateView):
def get(self, request, *args, **kwargs):
data = {
'order_id': 88888,
'subject': 'haha',
'rn_check': 'F',
'app_pay': 'T',
}
url = 'http://some-third-party-api-url?order_id=88888&subject=haha&...'
return HttpResponseRedirect(url)
Run Code Online (Sandbox Code Playgroud)
但是我想将这个第三方api用作包装的SDK,比如
class TestView(TemplateView):
def get(self, request, *args, **kwargs):
from sucre.alipay_sdk.base import Alipay
from sucre.alipay_sdk import alipay_config
from django.http import HttpResponse
alipay = Alipay(alipay_config)
data = {
'order_id': 88888,
'subject': 'haha',
'rn_check': 'F',
'app_pay': 'T',
}
'''alipay api is wrapped in a sdk'''
'''and return a requests.models.Response instance'''
result = alipay.api('pay', data)
return HttpResponse(result)
Run Code Online (Sandbox Code Playgroud)
和api代码:
def …Run Code Online (Sandbox Code Playgroud) 如果端点'/ tokens/verify'的令牌错误,我返回状态码401,并且不需要向用户发送任何正文内容.
为application/json内容类型发送空体是否正确?
response ×10
http ×2
javascript ×2
symfony ×2
ajax ×1
api ×1
asp.net ×1
c# ×1
caching ×1
cross-domain ×1
django ×1
forward ×1
get ×1
header ×1
hide ×1
http-error ×1
httprequest ×1
httpresponse ×1
iframe ×1
java ×1
json ×1
jsonp ×1
paw ×1
post ×1
python ×1
request ×1
symfony-2.1 ×1