jquery ajax() function not working properly or even being acknowledged
P粉947296325
P粉947296325 2023-09-06 11:40:35
0
1
562

I am currently developing a project using jquery ajax functions. I just want the ajax function to display some text from a file on the server when a button is clicked, but when I click the button it does nothing. I tried adding an error message but that doesn't seem to work either. I've made sure to use a version of jquery that supports ajax functionality, I've even copied and pasted code from a source that I know works, but nothing seems to work.

My java script file

window.onload=loadDoc(); $(document).ready(function(){ // the function that should be getting called $("#accountInfo").click(function(){ $.ajax({url: "accountPerks.txt", error: function(xhr, status, error) { var err = eval("(" + xhr.responseText + ")"); alert(err.Message); }, success: function(result){ $("#perksDiv").text(result); }}); }); }); //everything below here are functions for separate pages $(document).ready(function(){ $("#member1Info").click(function(){ $("#BandMember1").css("visibility", "visible"); }); }); $(document).ready(function(){ $("#member2Info").click(function(){ $("#BandMember2").css("visibility", "visible"); }); }); $(document).ready(function(){ $("#member3Info").click(function(){ $("#BandMember3").css("visibility", "visible"); }); }); function newAlbum(){ var node = document.createElement("li"); var textNode = document.createTextNode("aaaaallllpxas(2023)"); node.appendChild(textNode); document.getElementById("albumList").appendChild(node); $("#sneakPeak").css("visibility", "hidden"); } var getAlbum = document.getElementById("sneakPeak"); getAlbum.onclick=function(){ newAlbum(); } function loadDoc() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function(){ if(xhttp.readyState == 4 && xhttp.status == 200){ document.getElementById("ExtraText").innerHTML = xhttp.responseText; } }; xhttp.open("GET", "TourInfo.txt", true); xhttp.send(); }

The page I want the text file to appear on

     CMP204 Unit Two Coursework Template   

User Profile

"; ?> // this button should display the text from the server

// the text from the server should be showing in this paragraph

add gig attended
edit gig you want to change
select gig to replace it with
delete gig attended

Here are all the gigs you have attended


P粉947296325
P粉947296325

reply all (1)
P粉908138620

Use only 1 document function, if you use too many $(document) functions, only the last function will be returned in the response.

$(document).ready(function(){ //use one doc ready and do your code in this })

And use the other functions you want to run that will be loaded in the window.load function

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!