JQuery-JSONP plugin fails when placed in a directory

I have a HTML page that uses the JSONP Plugin to gracefully handle errors in my JSONP call. My problem is quite convoluted (and I hope it has a simple, simple "D'Oh!" Solution :)). When the .js file is in the same directory as the HTML page and loads like this:

<script type="text/javascript" src="jquery.jsonp.min.js"></script>

      

Everything works well. But if I move it to the internal JS directory where all my other JS files are:

<script type="text/javascript" src="js/jquery.jsonp.min.js"></script>

      

It always calls the error function. I traced it with FireBug and calls the function $.jsonp

, but it goes straight to the error function. The code itself looks like this:

$.jsonp(
  {
    url: ipUrl, 
    timeout: 30000,
    success: displayData,
    error: displayError
  }
);

      

Any ideas? I really want to post this in an organized manner. Thank you for your time.

A couple of facts: the page is tested locally (no web server). no permissions / security issues . There are other .js files in the same directory that load well. The error occurs in all browsers.

UPDATE : Based on Alex's suggestion, I downloaded the non-urgent version and put it in the js directory. I changed the link on the HTML page and rendered it using FireBug. The function MUST get the correct url and actually works!
I went back and forth from unminified to minicode and the result is clear: something messed up in the shorthand version!
However, I am wondering what could mess up the function in that its location matters ??? Should I just submit the unminified version and forget about it?

Update 2 - Solution : I minified the open file myself (I used Alex's link to get the C # code for JSMin ), I compiled and minified the file - and it worked. Then I compared it to the file I downloaded - the carriage return was screwed up. Upload the file again and everything works.

+2


source to share


2 answers


Just suppose, but if ipUrl is also local to the page (for testing), then maybe when the script is added from another directory, it tries to get into a local file that doesn't exist relative to its location.This will immediately call the error function.



Can you use the unminified version of the script to debug and see what the url is trying to remove?

+2


source


Have you tried to explicitly install callbackParameter

?



$.jsonp({
    url: ipUrl, 
    callbackParameter: 'nameOfTheCallbackParameterThatYourServerSideScriptExpects',
    timeout: 30000,
    success: displayData,
    error: displayError
});

      

0


source







All Articles