0

I'm having some problems with jQuery while loading an external page to get some data from mysql. The return var in the function loaded have the right data, but I am assuming it should be in the "d" variable, but it's empty.

This is the way I call the load() to the PHP script.

$("#msj_presupuesto").load("../Content/Scripts/ajax_circulares.php?accion=comprobar_presupuesto",{presupuesto:presupuesto}, 

    function(d){ ... }
3
  • What does that PHP page actually output? When you debug this in your browser's debugging tools, what is the actual response from the server? Commented Aug 25, 2015 at 13:37
  • I think you need to use ajax post method here instead of load which is basically used to load data from the server and place the returned HTML into the matched element. Commented Aug 25, 2015 at 13:44
  • the PHP makes a MySQL call, and pharse some sumbers. The result will be a variable with "0" in case we have no results or a string in case we have results. I dump the variable before the return and it's working right... Commented Aug 26, 2015 at 8:43

1 Answer 1

1

This is the whole js function:

$("#presupuesto_inicial").focusin(function(){
    $("#msj_presupuesto:visible").fadeOut();

}).live("change",function(){
    var presupuesto = $(this).attr("value");

    $("#msj_presupuesto").hide();

    $("#msj_presupuesto").load("../Content/Scripts/ajax_circulares.php?accion=comprobar_presupuesto",{presupuesto:presupuesto},
        function(d){
            $(this).html("");
            if(parseInt(d) == 0){
                 $(this).html("<img src=\"../Content/Images/icono_ok.png\"/> Presupuesto inicial no usado en otra circular").show();
            } else {
                $(this).html("<img src=\"../Content/Images/icono_error.png\"/> Presupuesto inicial usado en otra circular").show();
                alert("Circulares con ese presupuesto: "+d.substr(0,d.length-2));
            }
        }
    );
});
Sign up to request clarification or add additional context in comments.

Comments

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.