Jump to content

PHP and url hash


themistral

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.