jsonp

JSONP request fails when https is used instead of http

不羁的心 提交于 2019-12-30 05:40:08
问题 I have an API client which makes a JSONP request using JQuery. Everything works fine when this API client's not using SSL however fails when the SSL is used. For example I have a URL http://apiclient.com and I am making following JSONP request from this domain: $.ajax({ url: url, dataType: "jsonp", contentType: "application/json; charset=utf-8", success: function(data) { $.each(data.services, function(index, service) { processService(service); }); } }); I see an appropriate request made to

jsonp comet hanging request causes ugly “loading” status on browsers

此生再无相见时 提交于 2019-12-30 05:25:10
问题 I'm using jsonp to do cross-domain comet requests, and the "loading" status is really annoying. Is there any way to suppress this with javascript? For those who are unfamiliar with jsonp, it basically injects a script tag, except in my case, I'm hanging the request on my server without returning the request until a later time. During this time, browsers see my request as a "loading" state. I am using this: http://code.google.com/p/jquery-jsonp/ Thanks in advance! 回答1: As far as I know, there

How can JavaScript save to a local file?

泄露秘密 提交于 2019-12-30 03:06:06
问题 There's already a solution for writing file JSON online but I want to save json file locally. I've tried to use this example http://jsfiddle.net/RZBbY/10/ It creates a link to download the file, using this call a.attr('href', 'data:application/x-json;base64,' + btoa(t.val())).show(); Is there a way to save the file locally instead of providing a downloadable link? There are other types of conversion beyond data:application/x-json;base64 ? Here's my code: <!DOCTYPE html> <head> <meta charset=

JSONP代码收藏

自古美人都是妖i 提交于 2019-12-29 21:30:59
摘抄自jQuery,用于JSONP请求。 var callback = 'callback_' + (new Date() - 0), url = 'http://localhost/', script = document.createElement("script"), head = document.head || document.querySelector('head'); window[callback] = function(data) { console.log(data); window[callback] = null; }; script.async = true; script.charset = 'utf-8'; script.src = url; script.onload = script.onreadystatechange = function( _, isAbort ) { if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) { script.onload = script.onreadystatechange = null; if ( script.parentNode ) { script.parentNode

Angular4 JSONP + JAVA代码

一个人想着一个人 提交于 2019-12-29 21:30:50
一、在app.module.ts模块中,注入JsonpModule模块 import {JsonpModule} from "@angular/http"; @NgModule({ imports: [ JsonpModule //注入JSonpModule模块 ] }) 二、创建服务httpService,并注入jsonp和map(分装好的服务 可以直接调用) import {Injectable} from '@angular/core'; import {Jsonp, URLSearchParams} from "@angular/http"; @Injectable() export class HttpService { private jsonpTimes = 0; // 用于记录jsonp请求的次数 constructor(private jsonp: Jsonp) { } jsonpGet(apiURL, req){ let params = new URLSearchParams(); //设置参数 for (let key in req) { params.set(key, req[key]); } params.set('format', 'json'); params.set("callback", `__ng_jsonp__.__req${this

Posting cross-domain JSON to ASP.NET with jQuery

╄→尐↘猪︶ㄣ 提交于 2019-12-29 06:29:10
问题 Got kind of a tricky problem. I'm working on a project where we need to allow receipt printouts when users check out on our site at a kiosk. For reasons relating to drivers and formatting, I am using COM automation with Word to handle printing out the receipts. I've wrapped this code up in a web service that runs on a local machine. The plan was to put a simple jQuery ajax call in the page html to the url of the local machine running the web service. This ajax call contains a json object of

Retrofit - removing some invalid characters from response body before parsing it as json

ぐ巨炮叔叔 提交于 2019-12-29 06:24:09
问题 I have an external web service that in the response body returns json but nested in parentheses, like this: ({"door_x":"103994.001461","door_y":"98780.7862376", "distance":"53.3"}) Using this code: class AddressInfo { String door_x; String door_y; } interface AddressWebService { @GET("/reversegeocoding") AddressInfo reverseGeocoding(@Query("x") double x, @Query("y") double y); } It obviously fails. This is the stacktrace: retrofit.RetrofitError: com.google.gson.JsonSyntaxException: java.lang

Retrofit - removing some invalid characters from response body before parsing it as json

只愿长相守 提交于 2019-12-29 06:24:03
问题 I have an external web service that in the response body returns json but nested in parentheses, like this: ({"door_x":"103994.001461","door_y":"98780.7862376", "distance":"53.3"}) Using this code: class AddressInfo { String door_x; String door_y; } interface AddressWebService { @GET("/reversegeocoding") AddressInfo reverseGeocoding(@Query("x") double x, @Query("y") double y); } It obviously fails. This is the stacktrace: retrofit.RetrofitError: com.google.gson.JsonSyntaxException: java.lang

I would like json_encode in PHP to return a JSON array even if the indices are not in order

吃可爱长大的小学妹 提交于 2019-12-29 06:09:20
问题 but according to this: http://www.php.net/manual/en/function.json-encode.php#94157 it won't. I'm using flot so I need to have an array with numeric indexes returned but what I'm getting is this: jsonp1282668482872 ( {"label":"Hits 2010-08-20","data":{"1281830400":34910,"1281916800":45385,"1282003200":56928,"1282089600":53884,"1282176000":50262,"1281657600":45446,"1281744000":34998}} ); so flot is choking. If I var_dump the array right before I call json_encode it looks like this: array(7) {

I would like json_encode in PHP to return a JSON array even if the indices are not in order

让人想犯罪 __ 提交于 2019-12-29 06:08:12
问题 but according to this: http://www.php.net/manual/en/function.json-encode.php#94157 it won't. I'm using flot so I need to have an array with numeric indexes returned but what I'm getting is this: jsonp1282668482872 ( {"label":"Hits 2010-08-20","data":{"1281830400":34910,"1281916800":45385,"1282003200":56928,"1282089600":53884,"1282176000":50262,"1281657600":45446,"1281744000":34998}} ); so flot is choking. If I var_dump the array right before I call json_encode it looks like this: array(7) {