Author Topic: Error on getData call  (Read 7677 times)

sudo

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 12
    • View Profile
Error on getData call
« on: May 15, 2014, 12:15:52 am »
I'm getting this error (apparently from the data back) :
Uncaught Error : SyntaxError: Unexpected token < pqgrid.min.js:9
g.remoteRequest.xhr.h.ajax.error pqgrid.min.js:9
jQuery.Callbacks.fire jquery-1.10.2.js:3048
jQuery.Callbacks.self.fireWith jquery-1.10.2.js:3160
done jquery-1.10.2.js:8237
jQuery.ajaxTransport.send.callback jquery-1.10.2.js:8778

So the table is populating correctly, just seeing the error in the console (debugger)

Here is the data back from the PHP....  captured with debugger in PHP - I validated here http://jsonlint.com/:


{"data":[{"id_studies":"12","country":"usa","study_name":"O34232","category_table":"Healthy","summary_table":"D-alanine mouthrinse medication","gender_table":"Male, Female","age_table":"18 - 30","compensation_table":"Volunteer - $3,300; Partner - $1,200","length_table":"Volunteer 13 overnights and 4 follow up; Partner 4 follow up appointments","qualifications":"Males, Age: 18-30, BMI:18-32, No children living at home, You must be a non-smoker","minimum_age":"18","maximum_age":"30","status":"","study_details":"<p><strong>Category<\/strong><\/p>\r\n<p>Healthy<\/p>\r\n<p><strong>Description<\/strong><br \/>\r\n<\/p>\r\n<ul>\r\n<li>You must be available for 13 clinical overnight stays, plus 4 follow-up visits<\/li>\r\n  <li>You must be in a committed relationship<\/li>\r\n  <li>Your partner must be available for 4 follow-up visits<\/li>\r\n<\/ul>\r\n<p><strong>Qualifications<\/strong><br \/>\r\n<\/p>\r\n<ul>\r\n  <li>Males<\/li>\r\n  <li>Age: 18-30<\/li>\r\n  <li>BMI:18-32<\/li>\r\n  <li>No children living at home<\/li>\r\n  <li>You must be a non-smoker<\/li>\r\n<\/ul>\r\n<p><strong>Age<\/strong><br \/>\r\n  18 - 30<\/p>\r\n<p><strong>Duration<\/strong><br \/>\r\n  Volunteer 13 overnights and 4 follow up; Partner 4 follow up appointments<\/p>\r\n<p><strong>Reimbursement<\/strong><br \/>\r\n  You may be compensated for time\/travel up to $3,300 for male treated subjects; $1,200 for their partner. Refer a qualified subject for this study receive $500.<\/p>\r\n","sort_order":null}] }


PHP Code: 
        echo "{\"data\":". json_encode( $rows ) ." }" ;




dataModel:

        studyObjTbl.dataModel = {
            dataType: 'JSON',
            location: "remote",
            method: 'POST',
            sorting: "local",
            sortIndx: "id_studies",
            sortDir: "up",
            url: 'php/TransactionHandler.php?transActionID=listStudies&team=USA',
            getData: function (response, textStatus, jqXHR) {
                return { data: response.data };
            }
        };


Any insight?  Thanks

sudo

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Error on getData call
« Reply #1 on: May 15, 2014, 01:26:04 am »
After digging in pqgrid.dev.js to locate error...... 

So the error gets thrown here...  line 2895 of pqgrid.dev.js :

         error: function(jqXHR, textStatus, errorThrown) {
            that.hideLoading();
            that.loading = false;
            if (typeof DM.error == "function") {
               DM.error.call(that.element, jqXHR, textStatus, errorThrown)
            } else {
               if (errorThrown != "abort") {
                  throw ("Error : " + errorThrown)  // error thrown here
               }
            }


but what is interesting is that the data does get processed with no errors after that in this previous part (line 2847 - 2887) of the pqgrid.dev.js

         success: function(responseObj, textStatus, jqXHR) {
            if (typeof DM.getData == "function") {
               var retObj = DM.getData.call(that.element, responseObj, textStatus, jqXHR);
               DM.data = retObj.data;
               if (PM.type && PM.type == "remote") {
                  if (retObj.curPage) {
                     PM.curPage = retObj.curPage
                  }
                  if (retObj.totalRecords) {
                     PM.totalRecords = retObj.totalRecords
                  }
               }
            } else {
               DM.data = responseObj.data;
               if (PM.type && PM.type == "remote") {
                  if (responseObj.curPage) {
                     PM.curPage = responseObj.curPage
                  }
                  if (responseObj.totalRecords) {
                     PM.totalRecords = responseObj.totalRecords
                  }
               }
            }
            that.hideLoading();
            that.loading = false;
            that._trigger("load", null, {
               dataModel: DM,
               colModel: thisColModel
            });
            if (raiseFilterEvent) {
               that._trigger("filter", null, {
                  type: "remote",
                  dataModel: DM,
                  colModel: thisColModel,
                  filterModel: FM
               })
            }
            if (objP && objP.callback) {
               objP.callback()
            }
         },



and my grip gets updated.   Any ideas on what's going on?

sudo

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Error on getData call
« Reply #2 on: May 15, 2014, 01:55:51 am »
I found the error....  came from another table being updated simultaneous.   :) :D