Evgeny Petrov2017-01-25 19:47:22
Evgeny Petrov, 2017-01-25 19:47:22

[ajax] Why is the POST request not reaching the php file?

I'm trying to implement a case purchase check on the site.
I make an ajax request from the case ID, the php script checks whether it was purchased.
If purchased - returns a response, based on which the roulette wheel starts scrolling on the page
. If the case is not purchased, a response is returned, based on which a window (sweetalert2) appears with the text "you need to buy a case" and two buttons: "Buy" and "Cancel".
By clicking on buy, another request is sent. The PHP file does not yet check the balance and does not buy the case, it simply gives the answer that the case has been bought (for testing). Or rather, it should give this answer, but in fact it doesn’t.
Either I messed up something with ajax, maybe the request was sent crookedly, or maybe I missed something in the php file.

Code links:

JS code: pastebin.
PHP code: pastebin.com/f9pm6LWW

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Rsa97, 2017-01-25

Does the developer console in the browser show a request being sent? Are the parameters in it correct? Does the webserver log show a request? The webserver error log does not show errors in the script?

tvelforce, 2017-01-26

$.post("http://test1.ru/inc/api.php",'&section=cases&cid='+cid,function(data) {});

Isn't it?
$.post('http://test1.ru/inc/api.php?section=cases&cid='+cid,function(data) {});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question