I have a problem with editor in jquery datatables.
I'd like to use this project -> https://editor.datatables.net/examples/advanced/htmlTable.html
So, I copy all code to my computer and I run this file, this is my code -> http://wklej.org/hash/cf232c385cc/
But, I get information from console: $.fn.dataTable.Editor is not a constructor
And I don't know what is a reason this error.
Can You help me? :-)
That kind of error normally indicates, that the function you are calling is not loaded correctly.
1) Are you loading the javascript containing the $.fn.dataTable.Editor function? Can you make sure it is loaded by checking your browsers developer tools?
2) Is your call to $.fn.dataTable.Editor wrapped by this line: $(document).ready(function() {...}? If not your code executes before the javascript for $.fn.dataTable.Editor is loaded and defined and will fail with said error.
If that doesn't help, can you please edit your question to include the code?
Related
My eCommerce website needs to run JavaScript code so a 3rd party can send the customer a gift. The JavaScript code worked on the Thank You page, but I need to have a few-day delay before the script runs, so I'm trying to do this with Zapier instead. But Zapier is giving the following error when the same code is used there:
The run javascript could not be sent to Code by Zapier. SyntaxError: Unexpected token <
Zapier Support could not help, and I couldn't find the solution in Zapier's documentation.
Can someone please help modify the short code below, so that it can be run by Zapier?
<script src="https://members.thirdparty.com/jsapi/fbDE_Voucher.min.js"></script>
<script>
window.onload = function(){
var fdDE_detail = {
"fbDE_sender":'12345-67890',
"fbDE_fullname":"'"+inputData.CustName+"'",
"fbDE_email":"'"+inputData.CustEmail+"'",
"fbDE_amount":inputData.VoucherValue,
"fbDE_business":54321,
"fbDE_message":'Thank you for your purchase!'
}
fbDEVoucher(fdDE_detail);
}
</script>
The variables CustName, CustEmail, and VoucherValue are from prior Zapier steps. The first 2 need to be within single quotes, and the third is an integer (not requiring quotes). Please see image below:
JavaScript code for Zapier
Does anyone know how to fix the above error (in bold) so this code runs?
Appreciate your help! Thanks.
Zapier's code runs in Node.js, which is a different environment than the browser-based JS your code was running in before.
First off, <script> tags aren't available, since that's HTML. Whatever code comes in through fbDE_Voucher.min.js will need to be loaded separately. If it's not too long, you can paste it into the code window (but there's a better solution, see below).
There's also no window global, but you don't need it anyway. So to get this close to working, it would be something like:
// doesn't work, fbDEVoucher is undefined
fbDEVoucher({
fbDE_sender: "12345-67890",
fbDE_fullname: inputData.CustName, // doesn't need to be re-wrapped in a string
fbDE_email: inputData.CustEmail,
fbDE_amount: inputData.VoucherValue,
fbDE_business: 54321,
fbDE_message: "Thank you for your purchase!",
});
That's all you would need, assuming your function is already defined.
The best option for you here is to create a custom Zapier integration. This gives you a more full-featured JS environment than a Code by Zapier step, plus dramatically more control. You can include the aforementioned file and call the function as needed. There's docs about that here: https://platform.zapier.com/
I have a simple problem that I am in search of a solution. I have a JSP that includes jquery-1.10-2. I have verified that it is pulling back the correct version in the Chrome console with $.fn.jquery. I have a script tag in the jsp file that has some jquery functions in it, but I also have included a javascript file that has some regular javascript functions in it as well.
I've moved a jquery function into the included .js file, but I am now getting a '$ is not defined' error from Chrome. Am I not able to mix standard javascript and jquery in one file? For some reason it doesn't appear to be working.
I get this from within Chrome's console:
Uncaught ReferenceError: $ is not defined
amidst all of the POJS in the file, I have put in at the end:
$(function() {
alert("HELLO!");
});
Simple enough of a test to run when the DOM is ready, yet nothing. Can anyone chime in here and give me a hint as to what I am doing wrong?
I checked this SO question: In what ways can I mix jQuery and vanilla JavaScript
From what I gleaned, it shouldn't matter?
I've been attempting to write a basic website for a school project, and have decided to create it using a hybrid of html and basic javascript. Currently, I have the following html code for part of the site:
HTML Code
With the javascript "ScriptWindow.js", called in line 6 as:
Javascript "ScriptWindow.js"
The main issue I have seems to be lines 11-15, where I attempt to call the javascript functions GetNext(), GetPrev(), etc. My Google Chrome developer tools tell me that the error on the site is "Uncaught ReferenceError: GetNext is not defined ", even though I thought I had defined it in the javascript file perfectly clear.
I've tried putting the javascript file through a bug tested, and there seems to be no error that I or it can find, which leads me to the presumption that the javascript file is not being properly called. I've tried pasting the javascript directly into the html code, but it still doesn't recognize that the functions are there.
This leads me to believe that it's some issue with how the onclick tries to find the javascript function, or that somehow I have placed the javascript in the wrong spot or perhaps it is not loading in time for the button to find it. I've tried moving the line where I reference the javascript to different places: At the end of the body section, before the body section, with the other two javascript declarations at the very beginning, but nothing seems to work.
If anyone could shed a little light on my issue, it would be wonderful. I am completely new to javascript, so I realize that there's probably a silly mistake (Or a big one) that I'm overlooking. Thanks for your time.
I'm new to Javascript so forgive me if I kill this question.
I've got a script to grab my latest twitter posts and place it on my blog:
http://www.joshkerr.com
It isn't working. The error I see in the console is "no method domReady." Yet another script I wrote runs just fine and if I step through my function, works fine.
Here is the strange part. If I include jquery further up in my file, I get the Twitter object working, but my search http://www.joshkerr.com/search/ stops working. So I suspect some kind of namespace issue going on.
How do I get my Twitter object to work again?
Since It is all client code, you can view source and see for yourself.
It looks like jeesh.min.js may be clobbering jQuery's $ object. Your search page throws the error "Object function h(a,b){return g(a,b)} has no method 'getJSON'". The jeesh.min.js file contains "function h(a,b){return g(a,b)}" and getJSON is a jQuery method, so there you go. I see your search page contains a block like
$(document).ready(function() {
// Your code here
});
It's usually considered good practice to wrap such code like so
(function($) {
$(document).ready(function() {
// Your code here
});
})(jQuery);
This ensures that $ is actually the jQuery object.
I just spent half an one our to find out what caused the Error-Message "Ci is not defined" in my JavaScript code. I finally found the reason:
It should be (jQuery):
$("asd").bla();
It was:
("asd").bla();
(Dollar sign gone missing)
Now after having fixed the problem I'd like to understand the message itself: What does Firefox mean when it tells me that "Ci" is not defined. What's "Ci"?
Update:
I'm using the current version of Firefox (3.0.3).
To reproduce, just use this HTML code:
<html><head><title>test</title>
<script>
("asd").bla();
</script>
</head><body></body></html>
To make it clear: I know what caused the error message. I'd just like to know what Firefox tries to tell me with "Ci"...
I don't know which version of FF you are using, but regardless, the message is probably referring to the fact that bla() is not a function available on the String object. Since you were missing the $, which means you were missing a function, ("asd") would evaluate to a string, and then the JavaScript interpreter would try to call bla() on that object. So, if you had the following code in your project:
String.prototype.bla = function() {};
// now this next line will execute without any problems:
("asd").bla();
So, it is possible that Ci is some internal Firefox symbol that simply refers to the idea of a function. That is my guess, I imagine you are going to need someone that knows something about Firefox's internals to get a better answer to this question...
UPDATE: I am running your example code in the exact same version of FF as you are, but it reports the error as:
Error: "asd".bla is not a function
Source File: file:///C:/test.html
Line: 3
Perhaps you have an extension/plug-in running that does something with this? Maybe some Greasemonkey script or something?
Jason seems to be right. Many plugins (e.g. Firebug, Geode) use Ci as a shortcut:
const Ci = Components.interfaces;
So the plugins seem to cause that strange error message.
Assuming it's CodeIngiter, it can't find the js file.