0

Im currently working in another project which Im modifying. And I have .jade .php .js files.

In the jade file which is index I import a couple of scripts to use in the view. Like this:

<script src="/lib/jquery-1.5.1.min.js"></script>
<script src="/socket.io/socket.io.js"></script>

The problem is that I need to use a more recent jquery lib to be able to use $.get, $.post or $.ajax BUT the

<script src="/lib/jquery.blockUI.js"></script> 

wont allow me to use like jquery-2.0.3.min.js, any work around here? It is in jade and haven't really worked with it until now.

I just need something that can execute/run a php script with javascript in it. Or is it possible to maybe execute a javascript file from another javascript file?

So it is basically trying to import two libs or merge the libs. And everything will be ok. Or some kind of work around to execute the script.

EDIT:

From my script.js

$.get('getId.php' , function( data ) {console.log(data)});

From my getId.php

<?php echo 'name' ?>

I don't get just 'name' when I try to get it I get the whole script as a string.

troligtvis
  • 133
  • 2
  • 8
  • what do you mean it wont allow you to use ? – lagbox Apr 29 '14 at 09:45
  • I mean if I include the newer jquery lib I can't use jquery.blockUI.js. I guess they removed something that let me use that lib in the newer version ? ; – troligtvis Apr 29 '14 at 09:46
  • then you cant if you want to keep using jquery blockui – lagbox Apr 29 '14 at 09:48
  • Yes exactly! That is why im asking if there is some kind of merge or a way to use both libs :) – troligtvis Apr 29 '14 at 09:50
  • 1
    you could use two jQuery versions....it's a bit overkill, but if blockUI is locking you to jQuery 1.5 then it may be your only option... http://stackoverflow.com/a/15383015/1097858 – OACDesigns Apr 29 '14 at 09:51
  • have you tried `jquery-migrate`? it will solve main compatibility issues – Mohammad Hossein Amri Apr 29 '14 at 09:52
  • alternatively you could try the jQuery migration plugin. http://blog.jquery.com/2013/02/16/jquery-migrate-1-1-1-released/ – OACDesigns Apr 29 '14 at 09:52
  • Yea tried the one with noConflict but couldnt get it to work. The migrate thing on the other hand sounds interesting. How does it work? Do I just change the jquery-migrate-x-x-x to the one I have and then just before that the one I need ? – troligtvis Apr 29 '14 at 10:10
  • why exactly do you need a newer version for the ajax request? if I recall correctly the ajax function is the same since jquery1.5 – gulty Apr 29 '14 at 10:12
  • @gulty I have no idea, but the thing is when I use a $.get()-request and in the php file just a echo 'name'; I get all the text in that document as a string :S I get " instead of just 'name' ... – troligtvis Apr 29 '14 at 10:14
  • that doesnt sound like a jquery version problem unless you can verify that on a later version the same requests outputs something else. you should add your php/jquery code to your post. – gulty Apr 29 '14 at 10:19
  • @gulty done. Nothing fancy about that code :) I really dont know what the problem might be. Tried the same code in a new place on the server and it works. It is just within this project with those libs I get this problem... – troligtvis Apr 29 '14 at 10:37
  • can you try the ajax version? maybe some datatype issue: $.ajax({ url:"getId.php", method: "GET", dataType: "html", success: function(data) { console.log(data); } }) – gulty Apr 29 '14 at 11:32
  • @gulty yes, tried that also. Thx anyway for trying to help :) – troligtvis Apr 29 '14 at 13:57

0 Answers0