I wrote a quick Ruby on Rails application to try out the grid. I had problems getting it to work with a list of “Advertisers”. It works with “Markets” and other examples. I kept stripping the code down to find the problem and eventually discovered that a certain URL given for the data fetch causes the problem. The problem shows up as the “Loading…” never leaving, the data is never fetched, the call to hide the toolbar never gets called. And the AJAX call to fetch the data never fires on the server.
Again, changing the URL text with the same code works.
Sample code:
I had a similar issue (with different urls, though). It turned out to be mod_security running on my server. It basically checks the url for certain patterns, and rejects them if they match. I had a long battle with my service provider to get them to drop it…
Since Im almost certain there's nothing on the client side that cares about the url, I'd guess you have the same issue.
One way to test this is to just type the url into the address bar – if it fails, you know where the problem is…
Also, if you have access to your server logs, you should be able to find the errors in there…
Mark
I had a similar issue (with different urls, though). It turned out to be mod_security running on my server. It basically checks the url for certain patterns, and rejects them if they match. I had a long battle with my service provider to get them to drop it…
[…]
One way to test this is to just type the url into the address bar – if it fails, you know where the problem is…
Thanks for the suggestion. Unfortunately, that isn't the case here. I'm running it on my local machine against a Rails WEBrick server. There are no errors in the log as the request never gets there. The URL pulls up fine in a browser. I can hand-code the URL for a JSON response and it works. Using Fiddler (on Windows) I can verify that the AJAX request is never made so it can't be a blocking issue.
Thanks for sharing that information though.
-Mark E.
Hello,
Could you please try with pure ajax and see the result. What you set as url is passed in grid (you can see this in the code) in ajax function. I mean:
$.ajax({
url : '/advertisers?nd='+new Date().getTime(),
dataType: 'json',
complete: function(…) {
…
}
});
See the result.
Regards
Tony
Using Fiddler (on Windows) I can verify that the AJAX request is never made so it can't be a blocking issue.
I think it /must/ be a blocking issue of some kind – because the url is passed direct to $.ajax, which (I've checked the source code) doesnt do any url checking before making the xhr request.
But if the request isnt even being sent, it would have to be on the client side… could it be your firewall/antispyware/add-blocking software? What browsers have you tried?
Also, I guess you put a full url into the browser – have you tried doing that for the grid url parameter?
Mark
Thanks for the suggestion. When I use the “/advertisers” in the URL it never responds. No error and nothing in the log. When I change it to “/dvertisers” (removing the “a”), it returns an error page from the server about missing params. This works the same when I directly enter the url like this “http://localhost:3000/dvertisers.json”. When I add some of the expected params it correctly returns the JSON results.
However, using Firebug, I set breakpoints in the javascript on the “complete” and it never completes when the url is “/advertisers”. When it is “/dvertisers” or something completely invalid like “/abc” it will at least complete. I have another URL “/markets” that is setup the same way and works correctly.
Thanks,
-Mark E.
Ok. I believe I have a nice reproducible test for demonstrating this. I've tested this running in a Ruby on Rails WEBrick server on Windows and now in Ubuntu Apache (using PHP) and the same problem occurs.
Here is what I did…
What I found is that when the grid is pulling data from server.php and adver.php it works correctly. This shows that the adver.php file copy change works too. But when I request from advertisers.php the grid freezes and the request for the page doesn't show up in the Firebug > Net tab. The grid appears to never finish initializing as there is no “reload” or search icons in the bottom left corner.
I can zip it all up and email it to someone if needed.
Thanks,
-Mark E.
markeric said:
Ok. I believe I have a nice reproducible test for demonstrating this. I've tested this running in a Ruby on Rails WEBrick server on Windows and now in Ubuntu Apache (using PHP) and the same problem occurs.
Here is what I did…
- Downloaded the “Demo Files (3.6)”. Actually contains 3.5, more on that in a sec (http://www.trirand.com/blog/?page_id=6)
- Downloaded the latest 3.6 jqGrid source.
- Updated the demo files to have the latest source.
- Setup the demo files in my Ubuntu machine in the apache folders, setup the database, verified working.
- Copied “server.php” to create “advertisers.php” and “adver.php”. All the internal contents are unchanged.
- Modified jsonex.js to change the URL that it fetches the data from.
- Ran jqgrid.html in a Firefox browser. Using Firebug to watch Net requests too.
- Selected “Loading Data” > JSON Data
What I found is that when the grid is pulling data from server.php and adver.php it works correctly. This shows that the adver.php file copy change works too. But when I request from advertisers.php the grid freezes and the request for the page doesn't show up in the Firebug > Net tab. The grid appears to never finish initializing as there is no “reload” or search icons in the bottom left corner.
I can zip it all up and email it to someone if needed.
Thanks,
-Mark E.
I'm betting you have Adblock (or Adblock Pro) installed…
|
1 |
<br />Mark<br /><br /> |
markw65 said:
I'm betting you have Adblock (or Adblock Pro) installed…
1 Mark<br />
You are absolutely right. I disabled Adblock Plus for the page and it works correctly. It makes complete sense now. Thanks for catching that.
Now I have to keep URL names in mind so they don't get blocked like that.
It's still odd that visiting the page /advertisers loads correctly, just not the AJAX (JSON) request to the same URL. Interesting.
I really appreciate your help!
-Mark E.
It's still odd that visiting the page /advertisers loads correctly, just not the AJAX (JSON) request to the same URL. Interesting.
A couple of possibilities…
I /think/ you said that it /did/ get blocked, if you just put “/advert…” in the browser's address bar, but not when you used the fully qualified url. So perhaps that particular pattern only matches domain-less paths.
Another possibility is that since its basically trying to block ads on the pages you visit, it may only block xhr and iframe (and perhaps popup) requests.
But this has made me realize that I need to choose my server-side filenames and paths very carefully – the adblock blacklist that I found had a /huge/ list of things it would block. I should probably install it just to make sure Im not violating any of them…
Mark
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top