Friday, February 18, 2011

Workd around to pass external URLs in Ajax Call.



In our Twitter multipost script, "Ajax call" used to fail when passing external URL as GET method parameter.

This error won't occur if we use the url from the same domain. It looks like a security step taken by our Hosting.

I had tried to use "escape" in javascript code to url encode the parameter. But it didn't help.
So, I manually done this encoding.

i-e replaced in the "http://" with "### in javascript by adding below line.
msg=msg.replace("http://","###");
 And in php script , I replaced it again to "http://" by adding below code.
$twmsg=str_replace("###","http://",$twmsg);

It works fine. Anyway, it may not be the standard approach. There should be some other effective way. If you know that way, you can share it thro' the comments.



You can bookmark this blog for further reading, or you can subscribe to our blog feed.

No comments:



Thanks for visiting our blog


twitterrss facebook linkedin YouTube subscribe


Subscribe via email

Enter your email address: