开发者

"JQ is not defined" even though jquery is included

OK so person on http://foobar.com uploads to http://upload.foobar.com/cgi-bin/upload.cgi

upload.cgi returns:

<script language="javascript" type="text/javascript" src="http://upload.foobar.com/jquery-1.3.2.min.js">
</script>
<script language="javascript" type="text/javascript" src="http://upload.foobar.com/uploader.js">
</script>
<script language="javascript" type="text/javascript">
UploaderRemote.redirectAfterUpload('http://foobar.com/proxyajax.php?url=http://upload.foobar.com/finished.php&upload=a53d7d18d879b432a2', 1);
</script>

The information from upload.cgi is retrieved correctly, problem is the crossdomain restriction still applies.

Im attempting to just copy the js function that is being restricted to the subdomain so that it is separate from the main domain.

After importing jquery and uploader.js from the subdomain, I try running the function that was being restricted. (I omi开发者_如何学编程tted "parent." before UploaderRemote.redirectAfterUpload, not sure if it needs to stay there).

Problem is, javascript console says that JQ is not defined in uploader.js from upload.foobar.com, is there a way to explicit define it? I tried including jquery right before uploader.js, but no luck.

NOTE: http://foobar.com has its own jquery & uploader.js , but like i said before, the javascript (parent.Uploader.redirectAfterUpload) being grabbed from http://uploader.foobar.com/cgi-bin/upload.cgi isn't being allowed to access the functions of uploader.js on http://foobar.com


Try this: Have upload.cgi only return the javascript code you want to run

e.g.

redirectAfterUpload('http://upload.foobar.com/finished.php&upload=a53d7d18d879b432a2', 1);

When you retrieve this, just eval() it. You haven't provided any example of how you call upload.cgi or how you handle its response so I can't give proper code.

By the way, if upload.cgi is always supposed to redirect, you could have it return just the target URL.

If you want to investigate this further look for JSONP callbacks. This is pretty much the same technique.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜