How do I get BiwaScheme to run in JSFiddle? - javascript

I'd like to try to get BiwaScheme to run is JSFiddle, please.
The BiwaScheme page claims that all you need to do is:
<script src="biwascheme.js">
(display "hello, world!")
</script>
So I added the resource http://www.biwascheme.org/repos/release/biwascheme-min.js in JSFiddle, and the (display ...) in the JavaScript window.
http://jsfiddle.net/MsjMH/1/
However, nothing happens. The console error I am getting is:
// Uncaught SyntaxError: Unexpected string
What am I missing here?

You can evaluate a string as Scheme program with BiwaScheme.Interpreter.
Example:
http://jsfiddle.net/TaEEN/1/
(FYI) There is also BiwaScheme-fiddle: http://blackboard.biwascheme.org/

Related

Uncaught ReferenceError: method is not defined

I am getting this error in Chrome browser console. My page is using an external js file where the method is defined. Page is recognizing other methods but not recognizing this particular method.
Uncaught ReferenceError: getBillingAndShipping_AJAX is not defined at
<script type="text/javascript">
//<![CDATA[
Method1();Method2();Method3();updatecalender();UpdateItemDetailHeader();getBillingAndShipping_AJAX('0',1,0,0,'','False',''); EnableDisableHeaderInfo_ReviseOrder(false);DisableControlForContractorAndCS(true);HideDeleteForDependentItems();GetTimeDifference();hideinactive('content');$(document).ready(function() {changeoptions_user();if(typeof callAutocomplete!='undefined'){callAutocomplete();} });$(document).ready(function () {if($.browser.msie) {$('input:radio').css({ border:'none'}); $('input:checkbox').css({ border:'none'}); } });if(typeof js_load!='undefined') js_load();
var Page_ValidationActive = false;
This is my server side script.
I had tried both ScriptManager/ClientScript methods like RegisterClientScriptBlock and RegisterStartUpScript, but no luck. Please help.
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Bind Billing Shipping DDL", string.Format("getBillingAndShipping_AJAX('{0}',1,1,{1},'{2}','{3}','{4}');",
hdnFactoryID1.Value,
miCustomerType,
stVendorCode,
mbIsReviseOrder,
msEdiId), true);
Thanks all. I got the fix. I moved my js method on the page itself and it got recognized. It was not recognized if it was in js file. I dont know why. Its weird.

How to trace <script> elements/errors with Codeception with phantomjs/Selenium?

I've set up acceptance tests with codeception and phantomjs.
My website contains script elements:
<script src="/bla/test.js" type="text/javascript"></script>
The JavaScript file looks like this:
Bla = {
request: function(var) {
}
};
It looks like the content cannot be found since one of the buttons contains
onclick="return Bla.request('100')"
Running the acceptance test which clicks on this button shows me:
[Selenium browser Logs]
17:10:24.876 WARNING - SyntaxError: Parse error
17:10:25.121 WARNING - ReferenceError: Can't find variable: Bla
onclick (http://localhost/bla)
Screenshot and page source were saved into '/var/www/bla/_output/' dir FAIL
Does the first parse error already mean that the files have been loaded but contain errors? If so, how can I see the exact parse errors?
Requesting the JS file manually in the acceptance test works and it is the correct file (as the output shows):
$I->amOnPage('/bla/test.js');
I run codeception with the option --debug and looked at the output files where everything looked correct. How can I see if the JavaScript file has been imported correctly and if the parse error means that it failed, how do I get more information about the error?
edit:
Even if the parse error is not present I cannot access variables from a different JavaScript file.
When I have multiple script elements:
<script src="/bla/test0.js" type="text/javascript"></script>
<script src="/bla/test1.js" type="text/javascript"></script>
I get an error:
ReferenceError: Can't find variable: Bla
in file test1.js if it was defined in test0.js. This works in the normal browser without errors.

How to handle error 'console is undefined' in powershell?

Just a simple .js file in one of my drive which contains code
var x=3;
function numSqaure(x)
{
return(x*x);
}
var sentence="The square of" + x + "is" + numSqaure(x);
console.log(sentence);
I'm trying to run it through Powershell but it shows an error 'console' is undefined .
How to handle this error? I want it through Powershell only.
Javascript files are made for being executed by a browser, not directly in console unless you're using Node.js or something similar.
Create an HTML with a script tag like this:
<script src="c:\whatever\folder\you\choose\yourscript.js"></script>
and enter developer tools in browser. There this error won't happen anymore and console will exist.

Uncaught SyntaxError: Unexpected token < in JQuery UI Maps plugin? Works locally, not on the server

I'm working on a fairly simple site using Twitter Bootstrap. I'm having an issue with getting my Google Maps plugin to work. On localhost using Apache, it works fine. On the server, also Apache, it does not. I get this error:
Uncaught SyntaxError: Unexpected token <
On the first line of this file (jquery.ui.map.min.js):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html><head>
<title>Menu for /assets/js/jquery.ui.map.min.js</title>
</head><body>
<h1>Menu for /assets/js/jquery.ui.map.min.js</h1>
<hr />
<pre> jquery-ui-map</pre>
<pre> d[e]}];e=function(){return'\\w+'};c=1;};while(c--)if(k[c])p=p.replace(new</pre>
</body>
</html>
Here is a link to see the problem:
http://jhfc-law.com/contact.html
Again, the map and everything work fine locally. I'm sure the server is reading that DOCTYPE line as an issue due to the opening <, but I'm unsure how to fix this. It's causing this error as well (since the first file is breaking, gmap isn't being initialized so I can't use this following line):
Uncaught TypeError: Object [object Object] has no method 'gmap'
Which is in this method in my scripts.js file (which is being loaded after the previous file):
jQuery(document).ready(function() {
var position = new google.maps.LatLng(31.22633, -85.39422);
$('.map').gmap({'center': position,'zoom': 15, 'disableDefaultUI':true, 'callback': function() {
Uncaught TypeError: Object [object Object] has no method 'gmap'
var self = this;
self.addMarker({'position': this.get('map').getCenter() });
}
});
});
Any help is appreciated!
T
Your map javascript isn't on the server. This is what you're linking to: http://jhfc-law.com/assets/js/jquery.ui.map.min.js
Furthermore, it looks like the correct (?) link is broken as well: http://jhfc-law.com/assets/js/jquery-ui-map

Google Chrome: JavaScript Error Message

When using Google Chrome, I receive the following error message:
Error:
Uncaught SyntaxError: Unexpected token <
It occurs directly after my doctype declaration at the top of my HTML page
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Any ideas what this JavaScript error message is? It only seems to occur with Google Chrome (works fine in Safari, Firfox and IE)
This problem occurred for me when I was using JQuery to load in HTML from an XMLHTTPRequest that was HTML, but the mime type was text/javascript.
So for example, I had some code such as:
jQuery.ajax({
data:'params=here',
success:function(request) {
jQuery('#country_list_container').html(request);
},
type:'get',
url:'/getHtml'
});
jQuery is sending a request to getHtml, and getHtml is returning a simple snippet of HTML, with a mime/type however of "text/javascript". The reason the getHtml action was returning text/javascript is because the accept header of the request from jQuery is:
"Accept:text/javascript, text/html, application/xml, text/xml, */*"
So, all I had to do was force a header of text/html and everything worked perfectly.
The parse error you are seeing is a result of Javascript trying to eval the content.
In my case it was caused by an eval() statement aborting. When I fixed the problem the error message disappeared.
At the present time (June 2010) Chrome Javascript has a buggy eval() statement. eval() will abort without issuing an error message if a variable in the eval() statement has been assigned the reserved word 'delete'. It took me almost a week to uncover this bug because eval() aborts without any warning or error message, and the abort has nasty side-effects.
I was using eval() to achieve this result: obj.delete = somevalue.
This code will cause an eval() abort:
var obj = new Object();
var x = 'delete';
var y = 2;
eval('obj.' + x + ' = y');
This code works:
var obj = new Object();
var x = 'delete';
var y = 2;
eval('obj[\'' + x + '\'] = y');
In summary, don't use eval() to construct obj.delete = somevalue. Use eval() to construct the equivalent statement obj["delete"] = somevalue.
Maybe the HTTP content type is not text/html or application/xhtml+xml?
I found this Google Groups question.
Some others are experiencing the problem but without resolution.
http://www.google.com/support/forum/p/Chrome/thread?tid=7e9f87870a37e401&hl=en
Try switching the order of your css and js declarations. Worked for me.
At the risk of dredging up an old thread (I figure its better to keep all the info in one place), Chrome is still throwing these errors it seems. I got the following while developing a site and tried all kinds of things with the page JS and PHP to get rid of it. The error I got was:
error in event handler for 'undefined': SyntaxError: Unexpected token ILLEGAL
chrome/EventBindings:183
Eventually while checking code validity in FireFox I stumbled across the answer as a warning that there was a '&' in some text that should be converted to '&' - once this was done the Chrome error went away.
Steve
If you are returning a response to an ajax request in JSON, make sure you use 'application/json' for the Content-Type.
If it's a Rails App check that the format.js is in the response_to block.
I had this problem when I was trying to set .innerHTML dynamically generated with php (it was generated multi-line).
Replacing new line characters by spaces solved the problem.
I also encountered this error in Chrome Dev Tools, and my cause was similar to Matthew O'Riordan's except it wasn't the Accept MIME-type but rather the broken AJAX URL.
I had rearranged my folder structure and forgot to update the URL; once I fixed the URL, the Dev Tools JS Error was gone.
Hope this helps! :)

Categories