1

ajax:

$.ajax({
type: "POST",
url: "calculator/panouri-simple/calcul-panouri-simple.php",
data:  $("#formular_comanda").serialize(),
success: function(result) 
{
     document.getElementById("show_panels").innerHTML = result;
},
error: function(result)
{
     console.log("Eroare:");
     console.log(result);
}
});

HTML:

<div id="show_panels"></div>

when I look into "View page source" on browser, there is no html code between <div id="show_panels"> and </div>.

result from ajax is returning some inputs and I call those inputs with another ajax, but in html page source, those inputs are not there.

They are visually in browser, but the html code is not present in source code. I hope you understand what do I mean here. Look at the photos.

I am calling those inputs names in a php file and I get undefined variabile .... This is my problem. Visually, the inputs are there but no html code.

enter image description here enter image description here

Debugger:

enter image description here

6
  • Have you put a breakpoint and made sure that result is anything other than undefined? What is it? Commented Dec 6, 2017 at 16:46
  • 1
    Do what @zero298 say, if is returning something, check if there is no other element with id show_panels Commented Dec 6, 2017 at 16:49
  • I used debugger right after succes ... result and result ="the html code I need"; Commented Dec 6, 2017 at 16:50
  • I will upload a photo with deubgger. Commented Dec 6, 2017 at 16:50
  • Please look at updated post and see the Debugger photo. Commented Dec 6, 2017 at 16:52

1 Answer 1

1

Can I ask why you're using the traditional JavaScript document.getElementById when you've loaded jQuery and are using the syntax for it? You use a jQuery selector $("#formular_comanda").serialize() when you send the data to .ajax. Why not do something like...

success: function(result) {
    $("#show_panels").html(result);
},

Is your PHP file calculator/panouri-simple/calcul-panouri-simple.php expecting any GET parameters? Or anything in the POST that isn't being sent? Does the error appear in the console (you wrote with console.log), since the thing didn't go through?

Is your jQuery snippet, where you call the .ajax statement, inside of an event handler like

$(document).ready(function() {
    // ...
});

or is it just in the source as it is?

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.