我有这样的网络服务:
http://<remote_domain_ip>/api/v1/search/?query=the_query
哪一份是JSON的回复文件。
我如何打造/满足一个名叫“JSON/ajax”的JQuery JSON/ajax呼声,以便我能够回头回来?
答复的形式如下:
{
"status_code":200,
"status_txt":"OK",
"field1":"abc",
"field2":"some_text"
}
我有这样的网络服务:
http://<remote_domain_ip>/api/v1/search/?query=the_query
哪一份是JSON的回复文件。
我如何打造/满足一个名叫“JSON/ajax”的JQuery JSON/ajax呼声,以便我能够回头回来?
答复的形式如下:
{
"status_code":200,
"status_txt":"OK",
"field1":"abc",
"field2":"some_text"
}
它取决于。 如果在<条码>a.com<>上说的话,而且你的网络服务也在同一地点,那么你就能够这样做:
$.ajax( path-to-your-service/WebMethodName , data, function(r){
// Success callback, you have your answer in r.d object
}, function(e){
// Error callback
});
但是,如果你在<条码>b.com上,网络服务位于<条码>a.com,那么你受一个名为。 换言之,除非你遵守某些规则,否则你可以使用美国航天中心电话(或XMLHttpRequest)从该网络服务处取数据。 http://www.w3.org/TR/cors/“rel=“nofollow noreferer” HTTP Header field, which has some cross-browser issues. 另一种方式是使用JSONP,这要求服务器支持。
为了使用JSONP,你应当使用j Query s $.getJSON(
)方法,并提供一条警示,在通过HTTP GET寄出的参数之外,说明关键因素。
$.getJSON( path-to-your-service?x=some&y=thing?callback? , function(r){
// Success callback. Your JSON object would be the r parameter
});
我建议,如果你是网络服务的创建者,如果你使用的话,请使用JSONP。 NET框架,我还建议你只使用Generic Handler,而不是一个网络服务,因为我们有许多问题组合网络服务。 但是,在你的服务器代码中,你应检查即将提出的GET申请,询问如何铺设钥匙叫ert。
callback({
a: a1,
b: b1,
c: c1
});
Understanding JSONP (the concept and the way it occurs) is very crucial. Without a deep understanding, your future maintenance would be a huge burden. I suggest reading this question.
You can t, assuming is not the same domain you re on. If you have access to remote_domain_ip, or can get them to host a file for you, you can use EasyXDM. There are similar work-around tools involving Flash you can try. Otherwise, you ll need to perform the request on the back end.
The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...
How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.
I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...
I have a div <div id="masterdiv"> which has several child <div>s. Example: <div id="masterdiv"> <div id="childdiv1" /> <div id="childdiv2" /> <div id="...
I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.
I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...
Ok, I m stumped. Basically, this script works fine in FF, but not in IE (6,7 or 8) - in which it returns an "Object doesn t support this property or method" error. Any ideas?: function ...
What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...