adding “??” to jQuery.ajax() URL results in parseerror, SyntaxError : Unexpected token ‘:’

I’m sending a jQuery (version 2.2.4) AJAX request and getting a jQuery parse error if I include “??” in the URL. For info on “??”, see the “data” portion of the jQuery.ajax docs.

To debug I removed all the extra URL params and added them back one-at-a-time to find out what was causing the parse error. The request is going to the server and being handled and JSON data is being returned. When it work, it works.

NOTE: The URLS below were copied from the Network tab of the Chrome debug console showing the actual GET requests sent to the server, so they’ve been process by jQuery.
NOTE: The “gstr_*” variables are all Strings and defined elsewhere.

When this URL is sent, it works. It calls the “success” handler and the data returned is JSON. Note that the “jqtag” URL param at end of URL is empty.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>https://s01-sbm-test.example.com/workcenter/tmtrack.dll?ScriptPage&scriptUUID=60ec112b-8630-4a37-a268-163f2c967c61&callFrom=URL&userid=&prjid=&tblid=1179&itemid=1&issueid=65150799&method=GET&src=jQuery_url&jqtag=&_=1727293513409
</code>
<code>https://s01-sbm-test.example.com/workcenter/tmtrack.dll?ScriptPage&scriptUUID=60ec112b-8630-4a37-a268-163f2c967c61&callFrom=URL&userid=&prjid=&tblid=1179&itemid=1&issueid=65150799&method=GET&src=jQuery_url&jqtag=&_=1727293513409 </code>
https://s01-sbm-test.example.com/workcenter/tmtrack.dll?ScriptPage&scriptUUID=60ec112b-8630-4a37-a268-163f2c967c61&callFrom=URL&userid=&prjid=&tblid=1179&itemid=1&issueid=65150799&method=GET&src=jQuery_url&jqtag=&_=1727293513409

Adding the “??” as a value to the “jqtag” URL param before calling the .ajax function causes it to fail with this error:

Error handler :: status=parsererror ; error=SyntaxError: Unexpected token ‘:’

https://s01-sbm-test.example.com/workcenter/tmtrack.dll?ScriptPage&scriptUUID=60ec112b-8630-4a37-a268-163f2c967c61&callFrom=URL&userid=&prjid=&tblid=1179&itemid=1&issueid=65150799&method=GET&src=jQuery_url&jqtag=jQuery22408158756807991197_1727293897743&_=1727293897744

Here is the data printed by the “dataFilter” handler. I’ve hard-coded the server app to send this response irrespective of params sent.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>DataType = "json"
Data = "typeof = string"
Data = "{
"arrayData" : [1, 2, "3", 4],
"name" : "myObjName",
"value1" : 17,
"value2" : 5.700000
}"
</code>
<code>DataType = "json" Data = "typeof = string" Data = "{ "arrayData" : [1, 2, "3", 4], "name" : "myObjName", "value1" : 17, "value2" : 5.700000 }" </code>
DataType = "json"
Data = "typeof = string"
Data = "{
   "arrayData" : [1, 2, "3", 4],
   "name" : "myObjName",
   "value1" : 17,
   "value2" : 5.700000
}"

Here’s the function called to do the GET request:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>const getDataDemo4_GET = () => {
let obj_demo4_ajax_get_results = {};
let ajax_get_settings = {
method: "GET",
async: false,
cache: false, // appends "_={timestamp}" to the GET parameters.
contentType:
"application/x-www-form-urlencoded; charset=UTF-8", // type of data we send
dataType: "json", // type of data we expect
// DEBUG :: print the data from server before jQuery processes it.
dataFilter:
function(str_data, str_dataType) {
console.log(`*** dataFilter *** "Call_ModScript_From_Form.js" jquery.Ajax GET dataFilter handler
DataType = "${str_dataType}"
Data = "typeof = ${typeof(str_data)}"
Data = "${str_data}"
`);
return str_data;
} ,
success:
function(obj_data, str_status)
{
console.log(` SUCCESS *** jquery.Ajax GET success handler ... status=${str_status}`);
obj_demo4_ajax_get_results = obj_data;
},
error:
function(jqxhr, str_status, str_err)
{
console.error(`"Call_ModScript_From_Form.js" jquery.Ajax GET error handler ... status=${str_status} ; error=${str_err}`);
},
};
// Call the ModScript.
console.log(` URL to send: "${gstr_modscript_url + "&userid=" + gstr_userid + "&prjid=" + gstr_prjid + "&tblid=" + gstr_tblid + "&itemid=" + gstr_recid + "&issueid=" + gstr_issueid + "&method=GET" + "&src=jQuery_url" + "&jqtag=??"}"`);
let jq_ajx_get = jQuerySBM.ajax(gstr_modscript_url + "&userid=" + gstr_userid + "&prjid=" + gstr_prjid + "&tblid=" + gstr_tblid + "&itemid=" + gstr_recid + "&issueid=" + gstr_issueid + "&method=GET" + "&src=jQuery_url" + "&jqtag=??" ,ajax_get_settings);
console.log("*** obj_demo4_ajax_get_results:");
console.table(obj_demo4_ajax_get_results);
}
</code>
<code>const getDataDemo4_GET = () => { let obj_demo4_ajax_get_results = {}; let ajax_get_settings = { method: "GET", async: false, cache: false, // appends "_={timestamp}" to the GET parameters. contentType: "application/x-www-form-urlencoded; charset=UTF-8", // type of data we send dataType: "json", // type of data we expect // DEBUG :: print the data from server before jQuery processes it. dataFilter: function(str_data, str_dataType) { console.log(`*** dataFilter *** "Call_ModScript_From_Form.js" jquery.Ajax GET dataFilter handler DataType = "${str_dataType}" Data = "typeof = ${typeof(str_data)}" Data = "${str_data}" `); return str_data; } , success: function(obj_data, str_status) { console.log(` SUCCESS *** jquery.Ajax GET success handler ... status=${str_status}`); obj_demo4_ajax_get_results = obj_data; }, error: function(jqxhr, str_status, str_err) { console.error(`"Call_ModScript_From_Form.js" jquery.Ajax GET error handler ... status=${str_status} ; error=${str_err}`); }, }; // Call the ModScript. console.log(` URL to send: "${gstr_modscript_url + "&userid=" + gstr_userid + "&prjid=" + gstr_prjid + "&tblid=" + gstr_tblid + "&itemid=" + gstr_recid + "&issueid=" + gstr_issueid + "&method=GET" + "&src=jQuery_url" + "&jqtag=??"}"`); let jq_ajx_get = jQuerySBM.ajax(gstr_modscript_url + "&userid=" + gstr_userid + "&prjid=" + gstr_prjid + "&tblid=" + gstr_tblid + "&itemid=" + gstr_recid + "&issueid=" + gstr_issueid + "&method=GET" + "&src=jQuery_url" + "&jqtag=??" ,ajax_get_settings); console.log("*** obj_demo4_ajax_get_results:"); console.table(obj_demo4_ajax_get_results); } </code>
const getDataDemo4_GET = () => {

   let obj_demo4_ajax_get_results = {};

   let ajax_get_settings = {
      method: "GET",
      async: false,
      cache: false,   // appends "_={timestamp}" to the GET parameters.

      contentType: 
         "application/x-www-form-urlencoded; charset=UTF-8",        // type of data we send
      dataType: "json",                                             // type of data we expect

      // DEBUG :: print the data from server before jQuery processes it.
      dataFilter:
         function(str_data, str_dataType) {
            console.log(`*** dataFilter *** "Call_ModScript_From_Form.js" jquery.Ajax GET dataFilter handler
               DataType = "${str_dataType}"
               Data = "typeof = ${typeof(str_data)}"
               Data = "${str_data}"
            `);
            return str_data;
         } ,

      success:
         function(obj_data, str_status)
         {
            console.log(` SUCCESS *** jquery.Ajax GET success handler ... status=${str_status}`);
            obj_demo4_ajax_get_results = obj_data;
         },

      error:
         function(jqxhr, str_status, str_err)
         {
            console.error(`"Call_ModScript_From_Form.js" jquery.Ajax GET error handler ... status=${str_status} ;   error=${str_err}`);
         },

   };

   // Call the ModScript.

   console.log(` URL to send:   "${gstr_modscript_url + "&userid=" + gstr_userid + "&prjid=" + gstr_prjid + "&tblid=" + gstr_tblid + "&itemid=" + gstr_recid + "&issueid=" + gstr_issueid + "&method=GET" + "&src=jQuery_url" + "&jqtag=??"}"`);
   let jq_ajx_get = jQuerySBM.ajax(gstr_modscript_url + "&userid=" + gstr_userid + "&prjid=" + gstr_prjid + "&tblid=" + gstr_tblid + "&itemid=" + gstr_recid + "&issueid=" + gstr_issueid + "&method=GET" + "&src=jQuery_url" + "&jqtag=??" ,ajax_get_settings);

   console.log("*** obj_demo4_ajax_get_results:");
   console.table(obj_demo4_ajax_get_results);

}

8

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật