全球旧事资料 分类
本文由我司收集整编,推荐下载,如有疑问,请与我司联系
JqueryAjax请求Si
atra应用
201211031156I’vebee
atthisforawhilebutammissi
gsomethi
gI’vejustsetupasimpleSi
atraappretur
i
gJSON
我这样做已经有一段时间了,但是我错过了一些东西。我刚刚设置了一个简单的Si
atra应用,返回JSON
get‘jso
’doco
te
t_typejso
datato_jso
Thisisworki
gfi
ea
dthe
thejavascriptI’musi
gtodoacrossdomai
requestis
这是正常的,然后我使用的javascript做一个跨域请求。getJSON“domai
jso
callback”fu
ctio
dataco
solelogdata
U
fortu
atelywiththisIjustkeepgetti
gtheerrori
theco
soleU
caughtSy
taxErrorU
expectedtoke
a
dalthoughI’vetriedajustusi
gtheajaxmethodi
steadIstillgetthesameresult
不幸的是,我一直在控制台中获得未捕获的Sy
taxErrorU
expectedtoke
虽然我尝试过使用。相反,我仍然得到相同的结果。
Isthisa
erroro
myserverorclie
tsidecodea
yhelpappreciated这是我的服务器或客户端代码的错误吗任何帮助表示赞赏。2Youme
tio
edyouaremaki
gacrossdomai
requestForJSONPyou
eedtowrapyourjso
respo
setomimicafu
ctio
callThereisaSi
atrahelperwhichmakesiteasy您提到您正在发出一个跨域请求。对于JSONP,您需要包装您的jso
响应来模拟一个函数调用。有一个西纳特拉的助手让这一切变得容易。1Hereworki
gexamplewithdiffere
tport这里是不同端口的工作示例RubywithSi
atraRuby与辛纳特拉
f本文由我司收集整编,推荐下载,如有疑问,请与我司联系
require‘rubygems’require‘si
atra’require“si
atrajso
p”get‘
oteall’dodata
“hello””hi””hallo”JSONPdataJSONPisa
aliasforjso
pmethodHTMLhostedo

apache
HTML托管在apache
headid“Head1”ru
at“server”titleE
glishtitleli
khref“StylesSitecss”
rel“stylesheet”
type“textcss”

li
k
rel“stylesheet”
href“codejqueryui1103themessmooth
essjqueryuicss”

script
src“codejqueryjquery1102js”type“textjavascript”script
script
src“ajaxgoogleapisajaxlibsjquery1102jquerymi
js”type“textjavascript”script
scripttype“textjavascript”fu
ctio
toupdatealter
ativeaddress
‘Updateprofile’clickfu
ctio
varkey“
ick
ame”vardetails

ick
ame’valajaxtype‘GET’url‘localhost4567
oteall’crossDomai

truedata‘‘dataType‘jso
p’successfu
ctio
respo
seDatatextStatusjqXHR
‘co
trolstatus’htmlrespo
seDataerrorfu
ctio
respo
seDatatextStatus
errorThrow
alert‘POSTfailed’textStatusscriptheadbodyform
id“mstform”method“post”ru
at“server”i
putr
好听全球资料 返回顶部