Jump to content

Can I add .php to a file using Jquery


Pavlos1316
Go to solution Solved by requinix,

Recommended Posts

I am using this to open contents into a modal window, but in the process I am passing it through loop.php to check if the page exists and then load. Is there a way to completely skip the loop.php file and load my clicked link?

$(document).ready(function(){

///////LINK in a Modal Window//////// 
$('#all').delegate('a.pop-lnk', 'click', function(){
var page = $(this).attr('id');
$('#gr-out').css({ opacity: 0.7, 'width':$(document).width(),'height':$(document).height()}).show();
$('#popup').css({'display': 'block'});
$('#popup').load("../help-file/loop.php?page="+ page);
});
});

The id attr I am getting from this code is my page's name but I need to add the .php extension if is possible so I can load the page.

Edited by Pavlos1316
Link to comment
Share on other sites

Is page a proper URL? Can you actually skip loop.php, like are the things it does not terribly important? Then sure: don't use loop.php and .load() the page directly.

loop.php does nothing important. just checking if page exists but that is carried out by the server.

 

I have eg 2 links:

<a id="test1" class="pop-lnk">
<a id="test2" class="pop-lnk">

By clicking the link I use my JQ code to open the information of test1.php in a modal window. But the loop.php takes the IDvalue from my <a> and adds the .php extension so JQ can load the file.

Can JQ add the .php extension so I skip loop.php?

Edited by Pavlos1316
Link to comment
Share on other sites

Sure. Javascript is a programming language. It can do things like add two strings together.

$('#popup').load("../help-file/"+ page + ".php"); // I'm guessing at the path

I am stupid :( I was trying your answer the last hour... Forgot to add the full path ../help-file/ that's why it wasn't working :(

Now that I saw it written by you I realized!!! Thank you by the way... I will mark it as best answer.

Edited by Pavlos1316
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.