0

So continue from this: Linking how PHP/HTML

Please check the answer i accepted, and i used the "BASEDIR" solution zneak came with.

Now i ran onto another problem.. in my ajax_framework.js i have:

$.ajax({url: "session.php", success: function(data){

how should i include BASEDIR onto this? i was thinking something about:

$.ajax({url: "'.BASEDIR.'session.php", success: function(data){

but this isnt PHP, so i think you cant? no? any help or maybe another method to come around this?

2 Answers 2

2

Javascript also supports string concatenation:

$.ajax({url: baseDir + "/session.php", success: function(data) {

You will need to set the baseDir Javascript variable in Top.php:

<script language="text/javascript">
    var baseDir = "<?php echo BASEDIR; ?>";
</script>
Sign up to request clarification or add additional context in comments.

2 Comments

What gets rendered? (View source)
now it works with the variable..! thank you too bad i cant accept both answers because the both works well and are the correct answers.. hope its ok Boris Guerey
2

Why not just set a BASEDIR variable into your template set by your php code ?

Update your php code like this :

   <?php define('BASEDIR', '..'); ?>
    // in top.php
    <?php if(!defined('BASEDIR')) define('BASEDIR', '.'); ?>
    <link rel="stylesheet" type="text/css" href="<?php echo BASEDIR; ?>/style.css"/ >
    <script type="text/javascript">
       var BASEDIR = "<?php echo BASEDIR; ?>";
    </script>

Then concatenate with +

$.ajax({url: BASEDIR + 'session.php", success: function(data){}});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.