Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Error: Unexpected Token < In Json At Position 0 Rate Topic   - - - - -

 

Posted 06 December 2019 - 01:21 PM #1

Hello, 

 

I have an Ajax post request , and after i submit the request i get an error: Unexpected token < in JSON at position 0. 

 

Here is my request:

function getData(url, obj) {
  var container = obj.parents('.cm-product-filters');
  var params = {
    method: 'post',
    result_ids: ajax_ids,
    save_history: false,
    caching: false,
    data: {
      is_ajax: true,
      features_hash: generateHash(container),
      security_hash: s_hash
    },
    scroll: '#my_id',
    obj: obj,
    security_hash: s_hash,
    callback: _getDataRespons
    };
    if (ajax_ids) {
       $.ceAjax('request', url, params);
    } else {
       $.redirect(url);
    }

    return false;
}
<div class="my_id cm-reload" id="my_id">
<form
  class="cm-ajax cm-product-filters"
  method="post"
  name="form_coffind"
  enctype="multipart/form-data"
  id="gform_5"
  action="{""|fn_url}"
 data-ca-target-id="my_id"
 data-ca-base-url="http://localhost/public_html/cscart?dispatch=pages.view_products"
>
  <input type="hidden" name="result_ids" value="my_id" />
<input type="hidden" name="redirect_url" value="http://localhost/public_html/cscart?dispatch=pages.view_products">
  <div class="gform_body">
    <ul
      id="gform_fields_5"
      class="gform_fields top_label form_sublabel_below description_below"
    >
      <li
        id="field_5_6"
        class="gfield gform_validation_container field_sublabel_below field_description_below"
      >
        <div class="ginput_container">
          <input
            id="button_cart_817"
            class="ty-btn ty-btn__primary cm-submit"
            type="submit"
            name="dispatch[pages.view_products]"
            value="Submit"
          />
        </div>
      </li>
    </ul>
  </div>
</form>
<!--my_id--></div>



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19983 posts

Posted 06 December 2019 - 01:36 PM #2

Try to change your code to something simple, like

<div id="my_id">
{$smarty.const.TIME}
<!--my_id--></div>

and check the result


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 

Posted 06 December 2019 - 02:11 PM #3

I get 1575641422.



 

Posted 06 December 2019 - 05:55 PM #4

I get the response in the Dev tools -> Network and i have tested the response and seems to be valid.



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19983 posts

Posted 09 December 2019 - 05:41 AM #5

I get 1575641422.

 

So request is correct. Possibly the reason in the response. Try to add custom code line by line to find a reason


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)