Reputation: 33
I have an issue where running the following code in the Chrome Javascript console throws the following error: Cannot read property 'ready' of undefined
Did I not instantiate the function properly? I am confused as to what I am doing wrong.
$(document).ready(function(){
setTimeout(function() {
$('select[name="ctl00$ContentPlaceHolder1$DropDownListSources"]').first().val("Plant/Unit Seed File");
}, 1000)
setTimeout(function() {
$('select[name="ctl00$ContentPlaceHolder1$DropDownListEquipmentTypes"]').first().val("Plant");
}, 4000)
document.getElementById('ctl00_ContentPlaceHolder1_ButtonImportNow').click();
})
Upvotes: 0
Views: 33
Reputation: 690
As I was saying in the comment, you need to have jquery
referenced to use the library. Unless you are stopped on a breakpoint on a page with a jquery
reference, the console of your browser won't be able to use the functionality provided by jquery
or any other external libraries.
If you look at the snippet below, you can see that there is a jquery
script tag. There are still javascript errors being thrown, but the error Cannot read property 'ready' of undefined
is no longer being thrown because of the jquery
reference.
$(document).ready(function(){
setTimeout(function() {
$('select[name="ctl00$ContentPlaceHolder1$DropDownListSources"]').first().val("Plant/Unit Seed File");
}, 1000)
setTimeout(function() {
$('select[name="ctl00$ContentPlaceHolder1$DropDownListEquipmentTypes"]').first().val("Plant");
}, 4000)
document.getElementById('ctl00_ContentPlaceHolder1_ButtonImportNow').click();
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Upvotes: 1