#1: In coding terms, the word is âdeprecatedâ, not âdepreciatedâ. Close words, though, and one that⌠rarely if ever gets used outside of coding, to my knowledge. #2: âit is deprecatedâ⌠what is âitâ? The load() method? Itâs not deprecated, but there was a different method in jQuery 1.x/2.x called .load(), which acted like .click() in that it was an event binder to the load event. That form of .load() has been replaced by the one youâre using now in jQuery 3.x. (You⌠are using jQuery 3.X, right?)
So hereâs the short of itâŚ
This is code that I had paid a professional coder in 2014. Once the project was finished I had other things going on and didnât test it. By the time I wanted to use it the coder had moved on and I couldnât reach him. Now I am revisiting. I had extensive menus and text on the target page, etc - so I completely stripped it down to the bare min. and I am getting the same error. I click on Page 1 link in menu, it logs once in the database. If I click it again, it usually logs 2 hits and the 3rd click I sometimes get between 10-20 hits to the database.
AjaxJavaScript.asp page:
<script type="text/javascript">
var urlVariable;
var formURL;
$(".actionlink").click(function () {
urlVariable = $(this).attr("href");
$(".main").load(urlVariable);
return false;
});
$("form").on("submit", function (event) {
event.preventDefault();
var formData = $(this).serialize();
formURL = $(this).attr("action");
$.ajax({
type: "POST",
url: formURL,
data: formData,
success: function (r) { $(".main").html(r); },
error: function (r) { },
async: true
});
});
</script>
Step 1 when debugging Javascript: Forget about your ASP/PHP pages. Take a look at the HTML source in your browser. Because thatâs the only thing that Javascript sees.
PS⌠and thanks for taking the time for the explanation. But honestly, itâs above my pay grade! I appreciate the things that you have helped me on in the past. Thanks!
Thatâs because youâre looking at the Event form of .load(), which, as was stated, existed only in version 1.x/2.x of jQuery. The AJAX form of .load() exists in 3.X (and if you look in W3schoolsâ jQuery AJAX section, is listed there as normal.)
Opposite. Because the Ajax form of .load() didnât exist until 3.0, invoking it in 1.X will cause the code as written to fail.
Okay, lets get a bit more archaic with our approach here. âIt donât workâ levels of debugging time.