Why adding '/' at the beginning of the path of the POST request, it is sent as GET?

There is a $.post request
$.post("/?do=shop&action=basket_add", {
 id: id,
 count: count,
 opt1: opt1,
 opt2: opt2,
 opt3: opt3
 }, function (data) {
loading_hide();
 if ( data == 'error' ) return false;

//shop_basket_show();
 if ( a.length ) a.html(btn_1 + btn_2);
 $( ".sb-cont.element-sidebar-body.cart-body ul" ).replaceWith( data );
 });

In the browser I see that it goes as a GET, while losing the contents of the parameters(id,count, etc.)
If the path be specified as '?do=shop&action=basket_add' , i.e. without '/' character at the beginning, it is sent as POST and everything is OK.
Tell me, please, what it can be connected.
July 9th 19 at 10:07
1 answer
July 9th 19 at 10:09
Solution
Try this:
$.post("/", {
 do: 'shop',
 action: 'basket_add',
 id: id,
 count: count,
 opt1: opt1,
 opt2: opt2,
 opt3: opt3
 }, function (data) {
loading_hide();
 if ( data == 'error' ) return false;

//shop_basket_show();
 if ( a.length ) a.html(btn_1 + btn_2);
 $( ".sb-cont.element-sidebar-body.cart-body ul" ).replaceWith( data );
 });

And you're trying to mix GET and POST parameters into one.
GET out to the index file, losing in General all paramter - Cecelia.Wate commented on July 9th 19 at 10:12
And if so, why leave the parameters as get parameters without a trailing '/' in the path - Cecelia.Wate commented on July 9th 19 at 10:15
I'm struggling to see why a POST request takes to GET.
Now try to figure out the situation. - Daphne_Roob commented on July 9th 19 at 10:18
In url "?a=b" codepen.io/anon/pen/oLgeVy request as expected goes up as a POST on the current page plus parameters, i.e. index.html?a=b (but still POST).
How do you determine that it goes as GET?
Maybe you have call divert, which in response to the POST makes a redirect and you see GET? - Daphne_Roob commented on July 9th 19 at 10:21
I'm sorry, I'm in the previous comments are confused, as GET goes when a / character is present.
The type of query I see in chrome in the network tab they appear as sent in the request. - Cecelia.Wate commented on July 9th 19 at 10:24
I have in FF and Chrome in both cases "?a=b" and "/?a=b" everything works as it should - sends a POST request to the specified url. Settings are not lost. I don't know how to help you. Could you make a screenshot of the Network tab? - Daphne_Roob commented on July 9th 19 at 10:27
A page I found where to click to repeat the situation? - Daphne_Roob commented on July 9th 19 at 10:30
If you take for example the "feedback" that you have triggered a redirect /?do=... on /index.php?do=... on the level that turns POST into GET and need to do then post directly to /index.php?do=... - Daphne_Roob commented on July 9th 19 at 10:33
ooo-ip-spb.ru/tovs/15531/registraciya-ooo-ne-vyhod...
And then click "Add to cart"
If possible, will explain more in detail about redirect. - Cecelia.Wate commented on July 9th 19 at 10:36
joxi.ru/8An0ywQfqa1p6m.png
The first line of your POST request, the third - the result of a redirect.
In the first line from the server and received 301 Moved Location: ...../index.php?.....
I don't know if that's the plan, but if something doesn't work, replace the queries "/?do...." to "/index.php?do...." - Daphne_Roob commented on July 9th 19 at 10:39
All because if you open ooo-ip-spb.ru then there is a redirect on ooo-ip-spb.ru/index.php - Daphne_Roob commented on July 9th 19 at 10:42
Okay, got it, thank you!
He somehow did not notice! - Cecelia.Wate commented on July 9th 19 at 10:45
: You're welcome, keep up the good work! - Daphne_Roob commented on July 9th 19 at 10:48

Find more questions by tags AJAXjQuery