开发者

load does not work with certain url's

I use a web service that lets me easily create a contact form and manages the messages for me. I have this direct link from them that works fine and opens a new page with the contact form.

This is the link: http://apps.cyberth.com/webform/?event=form.show&formId=8957&key=B5220027CF

I use jQuery in my site to load pages into divs and elsewhere on the site this piece of code works just fine:

$('#news').load("news.html #news");

But using an near ide开发者_高级运维ntical snip of code with the form url no longer works:

$("#contactForm").load("http://apps.Cyberth.com/webform/?event=form.show&formId=8957&key=B5220027CF");

What can be causing this? I read that it might be a security issue preventing jQuery Ajax from loading pages not stored on the local server.

Also how can I isolate what the issue is in the future?


as cross-domain requests are not allowed by browsers due to same-origin-policy.

one way is to make a web proxy, e.g

call your server proxy from the client like

$.ajax({
url:'/your/domain',
//other params
success:function(data){
//data received that is sent by the server
}
});

on your server side, which ever language/technology you are using make a request to the desired service, in you case it is http://apps.Cyberth.com/webform/?event=form.show&formId=8957&key=B5220027CF then send the response to the client side.

here are some useful links

http://devlog.info/2010/03/10/cross-domain-ajax/

http://json-p.org/

http://msdn.microsoft.com/en-us/library/dd573303%28v=vs.85%29.aspx

http://net.tutsplus.com/tutorials/javascript-ajax/quick-tip-cross-domain-ajax-request-with-yql-and-jquery/

http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/


AJAX can not cross domain for security reason.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜