1

I stuck. I try to make Ajax call from button click. Function is loading and responding HTML data. HTML data in format like "< div>...< /div >". When I open "http://domain.com/load_info.php?id=1" in browser, I get all HTML data. But when I try to load it by Ajax function, nothing is loading.

buttons

   <input type='button' onclick='getInfo(1);' value='Load Info' >

Ajax Function

  function getInfo(id_number){
        alert('function started with id =' + in_number); // this alert works fine
        $.ajax({
            type:"GET",
            data: { 'id': id_number },
            url : "load_info.php",
            dataType: "text",
            success: function(response) {
              alert('success');                    // this alert is not working
              $("#info").prepend(response);
            }
        });
  };

1 Answer 1

2

You could also use this approach if you are using jQuery:

$("button").click(function(){
    $.get("load_info.php",
    {
        id: id_number
    },
    function(data, status){
        alert("Data: " + data + "\nStatus: " + status);
    });
});
Sign up to request clarification or add additional context in comments.

1 Comment

I'm sorry, but this button is in google map infoWindow. And is generated "on the fly". I need to find solution by my example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.