antonyfal Posted December 8, 2011 Share Posted December 8, 2011 Hi i got a script that requires jquery 1.3.2.min.js, but when i include the 1.3.2.js my site does not work. When i check the included scripts i see that i already have 1.4.3.min.js on the page where i need this script to function. But without the 1.3.2.min.js the script does not work. So how can i upgrade it to use with 1.4.3.min.js ? here is code: me.emailCheckout = function() { var div = me.updateCartView( document.createElement("diver") ); diver = "<div class='Cart_items'>" + div.innerHTML + "</div>"; var name = jQuery("#name").val(); var adress = jQuery("#adress").val(); var datastring = 'div=' + diver + '&name=' + name + '&adress=' + adress; jQuery.ajax({ type: "POST", url: "email.php", scriptCharset: "utf-8", contentType: "application/x-www-form-urlencoded; charset=UTF-8", data: datastring, success: function(data) {alert(data);} }); eraseCookie('Cart'); }; Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/ Share on other sites More sharing options...
trq Posted December 8, 2011 Share Posted December 8, 2011 Nothing in that code is specific to 1.3.2 or 1.4.3, what errors are you getting? Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1295650 Share on other sites More sharing options...
antonyfal Posted December 8, 2011 Author Share Posted December 8, 2011 Its my lucky day Thorpe. I see you also on github. This is the topic: https://github.com/wojodesign/simplecart-js/issues/84#issuecomment-3056269 I have followed everything on this topic and when i hit the checkout button nothing happens.. Im missing something.. I cant include the jquery as its already included on the page, everything works except the email checkout function.. Please can you take a look.. On this page i followed everything by the book. I use 2.2 Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1295654 Share on other sites More sharing options...
scootstah Posted December 8, 2011 Share Posted December 8, 2011 So are you getting any Javascript errors? Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1295675 Share on other sites More sharing options...
antonyfal Posted December 8, 2011 Author Share Posted December 8, 2011 Hi, Im not getting any errors. I did some further checks. The code above does work with either version of Jquery. I am looking into the code for another way to do this. Maybe im missing something.. Ill post again if i find a solution. But for now the code above works. Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1295720 Share on other sites More sharing options...
antonyfal Posted December 8, 2011 Author Share Posted December 8, 2011 Hi Thorpe.. Heres my problem: <script type="text/javascript" src="http://www.mydomain.com/javascript/jquery-1.4.3.min.js"></script> I cant include this file cause its alreday included in my index.php file. If i do include the file again where the script requires it Jquery doesnt load period. Is there a fix to include it more then once? or is it possible to get a prototype function to achieve the same result above? regards Antony Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1295728 Share on other sites More sharing options...
Adam Posted December 8, 2011 Share Posted December 8, 2011 Maybe I'm missing something, but why don't you just modify the external script tag to point to the new version? Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1295737 Share on other sites More sharing options...
antonyfal Posted December 8, 2011 Author Share Posted December 8, 2011 Hi Adam. what do you mean by: "modify the external script tag" and how would i do that? Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1295743 Share on other sites More sharing options...
antonyfal Posted December 8, 2011 Author Share Posted December 8, 2011 sorry Adam my bad. It doesn't matter the version jquery any more.. I cant use the script tag in my html page period, as it bums my site. Any version of jquery. If i do a source check of the entire page (consiting of modules and components) i see that jquery is loaded already. BUT the script above doesnt call to the jquery period it just happens the the version that is loaded on the mainframe is 1.4.xx. I did a check with the two version together and both work with the function above. BUT on the page on its own, not when i view the page through my site preview. BUT you got a plan there. How would i point the abopve function to use the main Jquery 1.4xx ? so that i dont have to include it in the html page as well. Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1295748 Share on other sites More sharing options...
antonyfal Posted December 8, 2011 Author Share Posted December 8, 2011 OK no!! prototype also conflicting with my site -- i scrapped this !! the user must have paypal or google.. or shop some where else Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1295846 Share on other sites More sharing options...
scootstah Posted December 8, 2011 Share Posted December 8, 2011 I guess I am confused. Why don't you just change what is included already to instead use the newer version of jQuery? Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1295887 Share on other sites More sharing options...
Adam Posted December 8, 2011 Share Posted December 8, 2011 OK no!! prototype also conflicting with my site -- i scrapped this !! the user must have paypal or google.. or shop some where else Great business strategy. Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1295902 Share on other sites More sharing options...
antonyfal Posted December 8, 2011 Author Share Posted December 8, 2011 take a look here: if you can puzzle this one! http://www.phpfreaks.com/forums/index.php?topic=349516.0 it will solve my problem. I m not using Jquery and Prototype just looking for a simple normal ajax function. Mootools Bumms out, prototype bumms out, jquery bumms out-- so my last attempt is the basic ajax flat no anything else xml request.. OF!!! WHICH I KNOW ABSOLUTELY NOTHING BUT THINK IM ON THE RIGHT TRACK HERE__ http://www.phpfreaks.com/forums/index.php?topic=349516.0 Let me know Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1295923 Share on other sites More sharing options...
antonyfal Posted December 9, 2011 Author Share Posted December 9, 2011 I guess I am confused. Why don't you just change what is included already to instead use the newer version of jQuery? Heres why: I cant use the <script>include any version jquery in the page</script> Cause this is how the page is formed: main index.php Main index.php also has <script>jquery 1.4--</script>{ page with menu Page with header page1 (ancor jquery tab) page2 (ancor jquery tab) page3 (ancor jquery tab) page4 (ancor jquery tab) page5 (ancor jquery tab) page6 (ancor jquery tab) page7 (ancor jquery tab) page8 (ancor jquery tab) OUrpage(ancor store jquery tab) if i use the Jquery <script>include jquery here any version</script> The jquery tabs break:( and the page does not work - - } So as you can see the page does have jquery loaded, but it doesnt work on our page- Our page requires it direct into the page. What i have tried besides Jquery is: mootools, prototype, all conflict when i include them.. So now i am at a final attempt at a ajax xml call WHICH is not conflicting anything but is also not working if you can take a look at this post to maybe help there? http://www.phpfreaks.com/forums/index.php?topic=349516.0 this will solve my problem.. OR Regards Antony Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1296081 Share on other sites More sharing options...
antonyfal Posted December 9, 2011 Author Share Posted December 9, 2011 I got this in the Javascript which initialises the page function based on Prototype or Jquery: If i can get it to check global jquery before load we will have success:(I think): if( typeof jQuery !== 'undefined' ) $(document).ready(function(){StoreCart.initialize();}); else if( typeof Prototype !== 'undefined') Event.observe( window, 'load', function(){StoreCart.initialize();}); else window.onload = StoreCart.initialize; Maybe something like: if( typeof jQuery.Global !== 'undefined' ) $(document).ready(function(){StoreCart.initialize();}); else if( typeof Prototype.Global !== 'undefined') Event.observe( window, 'load', function(){StoreCart.initialize();}); else window.onload = StoreCart.initialize; So it will look for the Jquery in the mainindex of the example above-- This will solve the issue too. How can i do this? Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1296087 Share on other sites More sharing options...
trq Posted December 9, 2011 Share Posted December 9, 2011 How many posts do you want to have open on this subject? Don't double post. Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1296089 Share on other sites More sharing options...
antonyfal Posted December 9, 2011 Author Share Posted December 9, 2011 Can you solve one? one is a ajax problem which if sloved helps me too. The other is a jquery problem which if solved helps me too they just happen to have the same example thats all two different problems. Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1296090 Share on other sites More sharing options...
Adam Posted December 9, 2011 Share Posted December 9, 2011 antonyfal, you are making no sense. Please explain properly in sentences why you can't just replace the old jQuery library with the new one, because there's literally no reason why you can't do it. Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1296103 Share on other sites More sharing options...
antonyfal Posted December 9, 2011 Author Share Posted December 9, 2011 OK! here it is: Lets not worry about the jquery library versions any more it is no longer an issue Period. Whats happening here in my website page is: the main index.php loads jquery (GREAT! this is what we want) BUT the jquery does not reach the page with the original function:the first function i posted above. That page requires the <script>to include the jquery library in the page directly for the page to work</script> BUT!! if i include the jquery library again the page bumms as in the example above +3 posts. SO!! I tried to use Prototype.js to perform the original function posted. BUT!!! prototype also Bummed the page, SO!! Itried to use mootools to perform the original function i posted at the top of the page. BUT!! Mootools also bummed the page. SO! here we are! I have two possible solution that might work to solve this problem. Solution number one: is a ajax version of the original function POSTED above. OR To point the call to Jquery to the global Script call Which is loaded at the top of my main index.php file anyway.. BUT! I HAVE NO CLUE OF EITHER FIX My ajax knowledge is cruddy at best, and how to point the .JS file to the global <script call to the jquery library > well i dont even know if that is possible, and how to achieve it.. I have been playing with some ajax calls : but still the page does nothing: heres my last attempt to the ajax fix if you want to take a look at it: //basically the script mus use the me.emailcheckout to call the function something here is a miss me.emailCheckout = function() { function ajaxRequest(){ var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] if (window.ActiveXObject){ for (var i=0; i<activexmodes.length; i++){ try{ return new ActiveXObject(activexmodes) } catch(e){ } } } else if (window.XMLHttpRequest) return new XMLHttpRequest() else return false } var mypostrequest=new ajaxRequest() mypostrequest.onreadystatechange=function(){ if (mypostrequest.readyState==4){ if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){ document.getElementById("theResponce").innerHTML=mypostrequest.responseText } else{ alert("An error has occured making the request") } } } var div = me.updateCartView( document.createElement("diver") ); diver = "<div class='globalStoreCart_items'>" + div.innerHTML + "</div>"; var buyersalute=encodeURIComponent(document.getElementById("buyersalute").value) var buyerfirstname=encodeURIComponent(document.getElementById("buyerfirstname").value) var buyerlastname=encodeURIComponent(document.getElementById("buyerlastname").value) var buyerstreet=encodeURIComponent(document.getElementById("buyerstreet").value) var buyertown=encodeURIComponent(document.getElementById("buyertown").value) var buyerregion=encodeURIComponent(document.getElementById("buyerregion").value) var buyercountry=encodeURIComponent(document.getElementById("buyercountry").value) var buyerpostalcode=encodeURIComponent(document.getElementById("buyerpostalcode").value) var buyercontact=encodeURIComponent(document.getElementById("buyercontact").value) var buyermobile=encodeURIComponent(document.getElementById("buyermobile").value) var buyeremail=encodeURIComponent(document.getElementById("buyeremail").value) var buyerprefpay=encodeURIComponent(document.getElementById("buyerprefpay").value) var buyerspecreq=encodeURIComponent(document.getElementById("buyerspecreq").value) var adminemail=encodeURIComponent(document.getElementById("adminemail").value) var adminstorename=encodeURIComponent(document.getElementById("adminstorename").value) var parameters = "div="+diver+"&buyersalute="+buyersalute+"&buyerfirstname="+buyerfirstname+"&buyerlastname="+buyerlastname+"&buyerstreet="+buyerstreet+"&buyertown="+buyertown+"&buyerregion="+buyerregion+"&buyercountry="+buyercountry+"&buyerpostalcode="+buyerpostalcode+"&buyercontact="+buyercontact+"&buyermobile="+buyermobile+"&buyeremail="+buyeremail+"&buyerprefpay="+buyerprefpay+"&buyerspecreq="+buyerspecreq+"&adminemail="+adminemail+"&adminstorename="+adminstorename mypostrequest.open("POST", "email.php", true) mypostrequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded") mypostrequest.send(parameters) }; something is just a little short.. Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1296107 Share on other sites More sharing options...
antonyfal Posted December 9, 2011 Author Share Posted December 9, 2011 I drew you a picture here: Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1296115 Share on other sites More sharing options...
Adam Posted December 9, 2011 Share Posted December 9, 2011 BUT the jquery does not reach the page with the original function:the first function i posted above. That page requires the <script>to include the jquery library in the page directly for the page to work</script> You're approaching this completely wrong. You have jQuery at your disposal, but instead of trying to fix the issue preventing you from use it, you're over complicating it. Why does it not reach the page? Why do you have to include it directly within the page? Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1296116 Share on other sites More sharing options...
Adam Posted December 9, 2011 Share Posted December 9, 2011 From your wonderful picture I'm guessing you're loading the content via AJAX? These pages, since they're loaded into the DOM, will be able to make use of the existing jQuery library included in the main page. You don't need to re-include it. Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1296123 Share on other sites More sharing options...
antonyfal Posted December 9, 2011 Author Share Posted December 9, 2011 Hi Adam. Its not including the jquery:( nothing i do is working, i will run another test to double check your theory-- ill get back to you on this.. But i just have to say i have tried everything i could think of, and so far no jquery worked-- so i thought Ajax--- heres why it need Jquery direct: the page loads a javascript and if jquery is not defined on the page the page loads the default loading-- here is the JS initializing script: //as you can see if jquery is not directly found the default will load-- so either find away to point this jquery to the main jquery-- or scrap jquery leave the default loading and use a ajax equivelent of the function i first posted.. //this is the original initializing page script if( typeof jQuery !== 'undefined' ) $(document).ready(function(){StoreCart.initialize();}); else if( typeof Prototype !== 'undefined') Event.observe( window, 'load', function(){StoreCart.initialize();}); else window.onload = StoreCart.initialize; // i need something like this: Maybe something like: if( typeof jQuery.Global !== 'undefined' ) $(document).ready(function(){StoreCart.initialize();}); else if( typeof Prototype.Global !== 'undefined') Event.observe( window, 'load', function(){StoreCart.initialize();}); else window.onload = StoreCart.initialize; Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1296197 Share on other sites More sharing options...
scootstah Posted December 9, 2011 Share Posted December 9, 2011 Is there a public link to your page? Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1296261 Share on other sites More sharing options...
antonyfal Posted December 9, 2011 Author Share Posted December 9, 2011 Public link OOOHHH ??!! what you say?? what lol no not yet my site is a surprise site.. Unique.. took me a year to develop.. Listen i have some update news: alert( 'posting stuff 1' ); // if this is a jquery alert type then it works and Adam was correct that the Jquery from the dom does load to the page, also i altered the If jquery !== 'undefined' to ==='undefined' and the page didnt load. So the Jquery does load... NOW This is what i did with the alert: i placed it at two point: the first point worked when i selected the checkout. The second point didnt work and nothing below the first point worked.. : me.emailCheckout = function() { alert( 'posting stuff 1' ); // here is the first point -- when i clicked the checkout this alert popped up. so the function does work when checkout is pressed... just for testing i simplified the code from here down-- var div = me.updateCartView( document.createElement("div") ); div = "<div class='StoreCart_items'>" + div.innerHTML + "</div>";// the storecart item does exists and is loaded with info on the purchase alert( 'posting stuff 2' ); here i added the alert second time around and removed the first alert but it never got activated-- and nowhere below the first point.. jQuery.post("//for the email.php page i tried abs url and relative url none worked email.php" , {div:div} , function(data) { alert( data ); }); eraseCookie('StoreCart'); // and the cookie still exists-- no emails were sent }; is there something wrong with the div var?? and the post is it absolute or relative url? the div var must send because it contains the data. On a page on its own this little script works but in the site dom page nothing-- I also changed the variable names but that didnt work either.. I got one more thing to try ill post back soon. Quote Link to comment https://forums.phpfreaks.com/topic/252731-how-can-i-upgrade-this-jquery-code-from-132minjs-to-143minjs/#findComment-1296358 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.