Where to put Error Alert in my JS [closed] - javascript

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Where I need to place Error Alert code in this JavaScript and if it is of any use in such JavaScript.
<script>
$(document).ready(function () {
$.get("ImagePreview?b_id=<%=id%>", function (responseJson) {
var $select = $("<div>").addClass("galleria").appendTo($("#imgas"));
$.each(responseJson, function (index, item) {
$("<img />").attr("src", item).appendTo($select);
});
});
});
</script>

Put an alert every odd line like alert("A"), alert("B") etc
Refresh the page
Remove every alert from your code and keep the one you like best
P.S: if you want to test the actual responseJson than alert is a bad idea.
Use console.dir(responseJson); inside your AJAX function.

Related

Call function inside href using Jquery [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
i have this link
Test
Now when i click directly on the link .. The alert get popped up in my window.
But, $("#myLink").click();
doesn't call the popup.
EDIT : I need to trigger the function inside href using jQuery
Solved --------- :
var x = $('#myLink').attr("href");
window.location = x;
Figured out..
var x = $('#myLink').attr("href");
window.location = x;
getting the href value and then targeting it .. solved the problem.
Try href="javascript:alert ('test')" or onclick="alert ('test')"

get webpage html element values without opening the page in new window or new tab using JavaScript [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Just like the title says I need a way to get the HTML of a webpage with out opening it in a new tab or window. I am making a chrome extension that will take element values from one page and append them to another page.
var htmlObject = gethtml("url");
would like some thing like this
You can use jQuery to get the content of the webpage:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
var htmlObject;
var yourURL = 'url.html';
$.get(yourURL, function(html) {
htmlObject = html;
});

How do I make every TR tag in a table a link with Perl and Javascript [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
If I have a tag called "post" and has href="something from perl" what should i use for javascript in order to make it clickable and redirects me to the link?
If you implement jQuery you can do something like this:
jQuery(document).ready(function($) {
$(".click").click(function() {
window.document.location = $(this).attr("href");
});
});
edit
assuming your tag looks like this
<tr class = "click" href = "<%= something from Perl %>">

JavaScript global function [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a function in a JavaScript file:
myscripts.js:
function myOn(node,event, selector, data, handler)
{
document.write("This text comes from an external script.");
}
and in the HTML file, I have this:
<body>
<script src="myscripts.js"></script>
...//some text and tags
<script>
myOn(outer, 'click','.deleteButton ', "", deleteDiv);
</script>
<body>
the function "myOn" don't run in the HTML file.
How i make this work?
I have searched the internet, but found some hard example for me to understand.
I need a simple example for beginner like me.
You have a syntax error in the function definition, there shouldn't be another parenthesis inside the parentheses
This line:
function myOn(node,event, selector, data, handler(eventObject))
should be:
function myOn(node,event, selector, data, handler)

How to trigger a JavaScript function after “Bootstrap: collapse plugin” transition is done [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I use this method
$jq('#indexClassData').on('hidden', function () {
// Do something…
expandIndexClass();
})
It does not work. What am I missing?
You need to wait for the "hidden.bs.collapse" event, not "hidden".
Scroll down to "Events" here: http://getbootstrap.com/javascript/#collapse-usage
thank you but i use another method
// ahmed taha to fix issue of documet coolapse
$jq('#indexClassData').on('shown.bs.collapse', function () {
expandIndexClass()
})

Categories

Resources