themistral Posted August 20, 2010 Share Posted August 20, 2010 Guys, Having a major headache here. I need to send an enquiry using jquery and php. The user can only send an enquiry if they are logged in - so it's a one click process. On the click (which is an <a> tag) the user's data is retrieved from the database and sent to the company they are enquiring about. When the link is clicked, a jquery popup is shown to notify the user that the enquiry has been sent. This all works. However, currently the enquiry is sent when the page loads and this is what I'm having trouble with. <a href="#e" onclick="openinfobox('Enquiry Sent', 1)" class="enq"></a> What I want to do is say if the URL contains #e, then send the enquiry, otherwise do nothing. I understand that the # portion of the url cannot be referenced by PHP. How on earth can I run php process to say only run this php process if there is a # in the url? Quote Link to comment https://forums.phpfreaks.com/topic/211282-php-and-url-hash/ Share on other sites More sharing options...
Psycho Posted August 20, 2010 Share Posted August 20, 2010 You will need to modify the function openenfobox() in some way. Without understanding the entire process I can't state what the best solution would be, but here is one: Add a third parameter to the openinfobox() function. In all the onclick calls add the third parameter using 'this' onclick="openinfobox('Enquiry Sent', 1, this)" You can then implement the solution in JS by having the function check the href value of the link object and if it doesn't contain "#e" then do not make the call to PHP. Or you could append the "#e" as another paramter tot he AJAX call and have PHP react accordingly. Quote Link to comment https://forums.phpfreaks.com/topic/211282-php-and-url-hash/#findComment-1101636 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.