Asked  7 Months ago    Answers:  5   Viewed   32 times

Today this caught my attention on jQuery's API Documentation for the closest selector:

.closest( selector [, context ] )

What exactly does [, context] mean? I know I can put a variable or jQuery object there to set as the context. This itself isn't entirely clear to me, but the part in particular I'm asking about today is the square bracket comma ( [, ). What does this mean? I've also seen similar notation on's manual pages.

bool ob_start ([ callable $output_callback [, int $chunk_size = 0 [, ...

Is there some preliminary lesson I've missed? because this is greek to me and I can't be the only one who's looked at this and thought "WTF..." but ignored it and went on guessing, when I could have saved a lot of time...



It means that parameter is optional. You don't have to provide it and if you don't it will use the value you see listed there by default.

Wednesday, March 31, 2021
answered 7 Months ago

dataType - delete this one.

Add console.log and open console in Your browser

success: function (data) {
   console.log( data );

show Your console, and then You will see why. Maybe an unwanted char or php error

Second thing - there should be if stament like this (I supposed)

if (data == "1") // it is returning string, not integer.

You can also try to use switch case in success.

Wednesday, March 31, 2021
answered 7 Months ago

You're immediately calling an anonymus function with a specific parameter.

An example:


This alerts "peter".

In the case of jQuery you might pass jQuery as a parameter and use $ in your function. So you can still use jQuery in noConflict-mode but use the handy $:

  var obj = $('<div/>', { id: 'someId' });
Wednesday, June 9, 2021
answered 5 Months ago

this (in the context of a module) is the same as exports in node.js. However you should generally use exports/module.exports instead, so that it's explicitly clear what you're modifying.

Saturday, June 26, 2021
answered 4 Months ago

add target=_blank in your ajax success function like below

success: function(){'http://YOUR_URL','_blank' );

otherwise you can handle smartly to open your Excel download link in new tab with jQuery trigger function or etc.

Monday, July 19, 2021
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :