Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Fails when certain URLs used for data
10/11/2009
12:02
Avatar
markeric
Birmingham, AL
Member
Members
Forum Posts: 5
Member Since:
10/11/2009
sp_UserOfflineSmall Offline

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:

        <script type="text/javascript">
        var lastsel;
        jQuery(document).ready(function(){
        jQuery("#advertiser-list").jqGrid({
            // adding ?nd='+new Date().getTime() prevent IE caching
            url:'/advertisers?nd='+new Date().getTime(),
            editurl:'',
            datatype: "json",
            colNames:['ID','Name','Address','City','State'],
            colModel:[{name:'id', index:'id',resizable:false,width:35},{name:'name', index:'name'},{name:'address1', index:'address1'},{name:'city', index:'city'},{name:'state', index:'state'}],
            pager: jQuery('#advertiser-list_pager'),
            rowNum:10,
            rowList:[10,25,50,100],
            imgpath: '/images/themes/lightness/images',
            sortname: 'id',
            viewrecords: true,
            toolbar : [true,"top"],
            sortorder: 'asc',

            caption: "Advertisers"
        });
        jQuery("#t_advertiser-list").height(25).hide().filterGrid("advertiser-list",{gridModel:true,gridToolbar:true});

        jQuery("#advertiser-list").navGrid('#advertiser-list_pager',{edit:false,add:false,del:false,search:false,refresh:true})
        .navButtonAdd("#advertiser-list_pager",{caption:"Search",title:"Toggle Search",buttonimg:'/images/jqgrid/search.png',
            onClickButton:function(){
                if(jQuery("#t_advertiser-list").css("display")=="none") {
                    jQuery("#t_advertiser-list").css("display","");
                } else {
                    jQuery("#t_advertiser-list").css("display","none");
                }
            }
        });
        });
        </script>
        <table id="advertiser-list" class="scroll" cellpadding="0" cellspacing="0"></table>
        <div id="advertiser-list_pager" class="scroll" style="text-align:center;"></div>

I experimented with the URL and found that it works with "dvertisers" but not "advertisers". I played until I found that "advert" was all that was needed to break it. It doesn't break with "adver" though.

I really have no idea why this would be. I'm not any javascript guru so I don't really know how to step in and diagnose it internally.

Any help would be appreciated.

-Mark E.

10/11/2009
13:31
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

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

10/11/2009
13:43
Avatar
markeric
Birmingham, AL
Member
Members
Forum Posts: 5
Member Since:
10/11/2009
sp_UserOfflineSmall Offline

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.

11/11/2009
02:39
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

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

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

11/11/2009
10:22
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

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

11/11/2009
14:01
Avatar
markeric
Birmingham, AL
Member
Members
Forum Posts: 5
Member Since:
10/11/2009
sp_UserOfflineSmall Offline

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.

11/11/2009
15:34
Avatar
markeric
Birmingham, AL
Member
Members
Forum Posts: 5
Member Since:
10/11/2009
sp_UserOfflineSmall Offline

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...

  1. Downloaded the "Demo Files (3.6)". Actually contains 3.5, more on that in a sec (http://www.trirand.com/blog/?page_id=6)
  2. Downloaded the latest 3.6 jqGrid source.
  3. Updated the demo files to have the latest source.
  4. Setup the demo files in my Ubuntu machine in the apache folders, setup the database, verified working.
  5. Copied "server.php" to create "advertisers.php" and "adver.php". All the internal contents are unchanged.
  6. Modified jsonex.js to change the URL that it fetches the data from.
  7. Ran jqgrid.html in a Firefox browser. Using Firebug to watch Net requests too.
  8. 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.

11/11/2009
17:00
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

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…

  1. Downloaded the “Demo Files (3.6)”. Actually contains 3.5, more on that in a sec (http://www.trirand.com/blog/?page_id=6)
  2. Downloaded the latest 3.6 jqGrid source.
  3. Updated the demo files to have the latest source.
  4. Setup the demo files in my Ubuntu machine in the apache folders, setup the database, verified working.
  5. Copied “server.php” to create “advertisers.php” and “adver.php”. All the internal contents are unchanged.
  6. Modified jsonex.js to change the URL that it fetches the data from.
  7. Ran jqgrid.html in a Firefox browser. Using Firebug to watch Net requests too.
  8. 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...


Mark

11/11/2009
17:09
Avatar
markeric
Birmingham, AL
Member
Members
Forum Posts: 5
Member Since:
10/11/2009
sp_UserOfflineSmall Offline

markw65 said:

I'm betting you have Adblock (or Adblock Pro) installed…

Mark

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.

12/11/2009
15:44
Avatar
markw65
Member
Members
Forum Posts: 179
Member Since:
30/07/2009
sp_UserOfflineSmall Offline

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

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
46 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information