I suspect you are misunderstanding how this works.
I var_dump($_POST['edit']) and I'm getting NULL
The way you phrased your question, it sounds like you are not seeing that null in your console.log()
, which is what would happen if you had the var_dump
and called it with ajax. Instead, it sounds like you are loading weekly_deals.php directly in the browser and, since that is a GET request, not a POST request, and no parameters are being passed, it comes back empty.
however in the console.log, I'm seeing the value "post is here" string
Right, because javascript is making an HTTP request using the POST method and passing a parameter.
I think you may be confused about how an HTTP request works. To break it down, you have a resource which comes as a URI -- you know this as the web address. You can ask it questions in a few different ways -- GET, POST, PUT, etc. A web browser, when navigating to a page, issues a GET request to the resource. The web server returns the response and renders it.
When you make an AJAX request, you are doing something very similar as far as the request life cycle is concerned. When you make the request, the server renders the response and sends it back. That is why your console.log()
has what you expect to see -- because AJAX made the request the server side expected to get. When you navigate to the page directly in the browser, it is the wrong type of request and thusly you see the wrong response.