Sweet Alert Not Working - javascript

I want to integrate sweetalert with my project. but I'm having the following error
I've been looking for solutions to this problem quite a long time, but I still can not solve it
this is my html code
<link href="/vendors/sweetalert/sweetalert.css" rel="stylesheet">
<script src="/vendors/jquery/dist/jquery.min.js"></script>
<script src="/vendors/sweetalert/sweetalert-dev.js"></script>
<script type="text/javascript">
sweetAlert("a", "b", "error");
</script>
I had time to find a similar problem, by replacing swalto swalAlerttheir problem successfully repaired, but not with my problem
please help me. thx..

Your code works for me using the CDN links. Check your console to make sure you're not getting a 404 error when referencing the css or js files. Also, I'm linking to version 2. Is that what version you're using locally?
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.11.0/sweetalert2.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.11.0/sweetalert2.all.min.js"></script>
<script type="text/javascript">
sweetAlert("a", "b", "error");
</script>

Related

JQuery example doesnt work - "Object doesn't support property or method 'button'"

I know this question was already asked in several topics, I went over them but didnt find anything helpful. Its quite simple - jquery ui doesnt work for me. I would like to use their "button", downloaded their css file and tried to implement example from their page. However, I keep getting error
"JavaScript runtime error: Object doesn't support property or method 'button'"
Here are relevant parts of my code. In head:
<link href="/App_Themes/jquery/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="/App_Themes/jquery/jquery.js" type="text/javascript"></script>
<script src="/App_Themes/jquery/jquery-ui.js" type="text/javascript"></script>
And in body:
<script type="text/javascript">
$("button").button();
</script>
<button>Button label</button>
Script is easy, but I still keep getting error mentioned above. Anyone has an idea where could be a problem?
Thank you, Jozef
This should do the trick ;-)
$(document).ready(function () {
$("button").button();
});

I can't load Plupload 2.1.2 in my ColdFusion page

I'm seeing a Javascript error that's preventing PlUpload from working in my ColdFusion page. I've reduced the code down to the simplest example that shows the error. As you can see there isn't actually any ColdFusion in the code in this stripped down example. This is Plupload 2.1.2 that I'm using.
The html code below in a test.htm page loads without error. But if I change the file name to test.cfm it causes this javascript error:
"SyntaxError: missing } after property list" # line 1056 column 14 in the jquery.ui.plupload.js file.
Firebug shows the live example as being "width: Â self.options.thumb_width,". It looks like "Â " is being inserted somehow in front of the "self.options.thumb_width" variable so it isn't being handled correctly.
I'm stymied; can anyone help?
<!doctype html>
<html>
<head>
<title>Test</title>
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" type="text/css" />
<link rel="stylesheet" href="js/jquery.ui.plupload/css/jquery.ui.plupload.css" type="text/css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/plupload.full.min.js"></script>
<script type="text/javascript" src="js/jquery.ui.plupload/jquery.ui.plupload.js"></script>
</head>
<body>
</body>
</html>
I've got this working now. There seem to be two issues in the Plupload 2.1.2 download files that are easily fixed.
Fix 1: In the /js/jquery.ui.plupload/jquery.ui.plupload.js file, on line 1056 (in the "preloadThumb" function) - there is a double space that needs to be reduced to a single space. Removing the extra space fixes the issue so Plupload loads and runs as it should.
"width: self.options.thumb_width,"
needs to be changed to
"width: self.options.thumb_width,".
Fix 2: The other way to fix this issue is to load the minimized version of the file (which pretty much strips out all blank space so the double-space issue is handled).
A problem I see in the Plupload 2.1.2 download is that all the examples load the unminimized version, even in the production section.
The production example should be
"../../js/jquery.plupload.queue/jquery.plupload.queue.min.js"?
From the sample code head section:
<!-- production -->
<script type="text/javascript" src="../../js/plupload.full.min.js"></script>
<script type="text/javascript" src="../../js/jquery.ui.plupload/jquery.ui.plupload.js"></script>
<!-- debug
<script type="text/javascript" src="../../js/moxie.js"></script>
<script type="text/javascript" src="../../js/plupload.dev.js"></script>
<script type="text/javascript" src="../../js/jquery.ui.plupload/jquery.ui.plupload.js"></script>
-->
So either fix above effectively solves the problem.

prettyPhoto Not Working - Error: Not a Function

I'm having some issues with prettyPhoto on one of my clients website. Here is the link for reference: http://www.browardmicrofilm.com/pages/kodak-vizit-essential.html
I've used prettyPhoto on multiple other websites without issue. However for some reason, this website just doesn't want to perform the script properly. Instead of opening an image in the lightbox clone, it simply opens it in a new page. Perhaps it has something to do with the hosting but either way, wanted to see what professionals like you think!
I'm using Firefox 26 (Mac version) and I used Firebug to determine the error:
TypeError: $ is not a function
$(document).ready(function(){
I've tried numerous solutions, including one that made me change "$" to "window.jQuery and then for some reason the next line in the code creates the same error.
Here's the my code for those of you that wish to skip the entire page source code:
In my header:
<link href="../prettyPhoto.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../Scripts/jquery.prettyPhoto.js"></script>
<script type="text/javascript" src="../Scripts/jquery-1.6.1.min.js"></script>
The final script just before the closing body tag:
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("a[rel^='prettyPhoto']").prettyPhoto({
theme: 'light_rounded',
});
});
</script>
I know my links are good, which is why I'm not including them.
Vanilla jquery needs to be declared before any library built on top of it
<!--first, jquery-->
<script type="text/javascript" src="../Scripts/jquery-1.6.1.min.js"></script>
<!--then the rest-->
<script type="text/javascript" src="../Scripts/jquery.prettyPhoto.js"></script>
Error below is saying that jQuery is not loaded.
TypeError: $ is not a function
$(document).ready(function(){
Check your resources, my guess is that your paths are case sensitive and libraries are not being properly loaded.
<script type="text/javascript" src="../Scripts/jquery.prettyPhoto.js"></script>
<script type="text/javascript" src="../Scripts/jquery-1.6.1.min.js"></script>
Check your resources.
Make sure that jQuery is loaded before the plugin is loaded.
<script type="text/javascript" src="../Scripts/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="../Scripts/jquery.prettyPhoto.js"></script>
Ultimately I abandoned the prettyPhoto javascript and went with an alternative. Lightbox 2.0:
http://lokeshdhakar.com/projects/lightbox2/
It works just as I'd like and no problems.

Jquery "$.uniform is undefined" error

I am using uniformjs to style some html element but when i try to update an element such as a check box using
$.uniform.update('input[type=checkbox]');
I get the error
$.uniform is undefined
any one else have an idea how to solve this?
I have both jQuery and the uniform.js added to the page.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.uniform.min.js" type="text/javascript" charset="utf-8"></script>
What's weird is this worked when it was a regular HTML page and stopped working when i made it into a ASP.NET page and added custom form validators. Perhaps there is some clash?
Reason for this error is browser cant identify $.uniform which can be because of following two reasons:
You have not included uniform.js file to your page, check if a similar looking lines is present in your markup.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script src="jquery.uniform.js"></script>
You are referencing it before its been loaded (have you included it at the end of the page, after the markup?)
You have to load all your dependencies and the current library itself to make it work.
For your css:
<link rel="stylesheet" href="uniform.default.css" media="screen" />
For your javascript:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script src="jquery.uniform.js"></script>
Please, check this JSFiddle that I've build for you, showing uniformjs working.

Syntax error in JavaScript using Dreamweaver

I have a JavaScript code in Dreamweaver, but it tells me there's a syntax error on line 2. Where's the problem?
<link rel="stylesheet" type="text/css" href="scripts/rates/rates.css" />
<script src="scripts/rates/jquery-latest.js"></script>
<script>
$(document).ready(function() {
$("#responsecontainer").load("scripts/rates/ratesresult_alb.php");
var refreshId = setInterval(function() {
$("#responsecontainer").load('scripts/rates/ratesresult_alb.php?randval='+ Math.random());
}, 1800000);
});
</script>
<div id="responsecontainer">
</div>
the same script works on a site ak-invest.com and in the new website does not work http://69.73.130.182/~akinvest/index.php/en/kembimi-valutor
I am not seeing any syntax errors in the code presented. Are you sure that jquery is loading? Try adding a simple script to replace your current one:
alert($);
This should alert something if jquery is loaded.
You could also check in the html panel of firebug to make sure the libary is being loaded.
Another solution would be to load jquery from a known source such as the Google CDN so that you know you have it.
Example:
<link rel="stylesheet" type="text/css" href="scripts/rates/rates.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
$("#responsecontainer").load("scripts/rates/ratesresult_alb.php");
var refreshId = setInterval(function() {
$("#responsecontainer").load('scripts/rates/ratesresult_alb.php?randval='+ Math.random());
}, 1800000);
});
</script>
<div id="responsecontainer">
</div>
Change
<script src="scripts/rates/jquery-latest.js"></script>
to :
<script src="scripts/rates/jquery-latest.js" type="text/javascript" />
Older versions may not detect the jquery way of accessing variables and elements. You can ignore those errors and see if your script actually works. Did your script works well, despite of those errors?
Alternatively try changing adding type attribute as posted by Mateusz.
<script src="../scripts/rates/jquery-latest.js" type="text/javascript" />
or
<script src="./scripts/rates/jquery-latest.js" type="text/javascript" />
Your syntax error is almost certainly going to be in the included js file. And it looks like you didn't write it (it's a jquery library, right?) so the likelihood of there really being a syntax error in the file is rather low.
Therefore, what is actually happening is the file isn't at the path you're looking for it (it's a relative URI), and a HTML 404 page of some sort is being parsed as JavaScript instead of the JavaScript file itself.
Most probably.

Categories

Resources