3

Currently, I am using jquery, php and codeigniter to write a program - However, I've come across a problem.

When I write view file using the codeigniter php framework, I cannot execute the JQuery by using the URL 127.0.0.1/ci/welcome/passdataview/6/7. If I use 127.0.0.1/ci/welcome/passdataview, the JQuery script can be executed.

Can anyone tell me how to execute the jquery script with codeigniter parameter in URL?

<html>
<head>
<script type="text/javascript" src="../js/jquery-1.7.1.js"></script>
<script type="text/javascript">

$(document).ready(function(){
alert ("here");
});

</script>
</head>
<body>
<div><h2>demo 1</h2></div>
<input type="hidden" id="hidden1" value="<?php echo $username;?>">
<input type="hidden" id="hidden2" value="<?php echo $subject;?>">
</body>
</html>
2
  • <script type="text/javascript" src="/ci/js/jquery-1.7.1.js"></script> Commented Sep 16, 2012 at 9:00
  • 127.0.0.1/ci/welcome/passdataview/6/7 doesn't have any "parameter in URL". Is it meant to be something like 127.0.0.1/ci/welcome/passdataview?username=6&subject=7? Commented Sep 16, 2012 at 9:00

1 Answer 1

4

Might be your jquery file problem, try loading url helper and use this:

<script type="text/javascript" src="<?php echo base_url('js/jquery-1.7.1.js');?>"></script>

Works no matter how you changed your folder or directory path.

Sign up to request clarification or add additional context in comments.

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.