Javascript error in Custom Script

Hello.

I’m having a error in the console that breaks my script.

When I click in New and go to the detail form, one error display on console and than my script stops to work.

My script just work when I reload the page.
What can I do to solve this problem?
Thank you!

Can you share your code?

Of course.

But just an additional information, this error is happening before load my javascript.

above my code.
Please, if there’s any better way to do what I’m trying to do, let me know. I’m a js developer, but I don’t know so well the frappe framework, so I’m using the resources that I have.

var nome = null;
var program = null;

frappe.ui.form.on(“Program Enrollment”, “student”, function(frm) {
var kindOfStudent = frm.doc.application_status;
if (kindOfStudent == “New Student”){
frm.set_value(‘academic_year’, “33 Weeks”);
} else {
frm.set_value(‘academic_year’, “33 weeks renewal”);
}

frm.set_value("academic_term", "33 Weeks (25 Course /  8 Holidays)");

frm.set_value("fee_structure", frm.doc.student_program.substr(0, frm.doc.student_program.length - 1));

msgprint(__("Please, complete the fee structure field with the name of the school to complete the amount price."));

nome = frm.doc.student_name;
program = frm.doc.student_program;

});

$(“.btn.btn-primary.btn-sm.primary-action”).click(function(){
if ($(“.btn.btn-primary.btn-sm.primary-action”)[0].innerText == “Submit”){
$.ajax({
url : “http://www.mundiallanguages.com/services/sendEmail.php”,
dataType: ‘text’,
type: ‘POST’,
contentType: ‘application/x-www-form-urlencoded; charset=utf-8’,
data : {student_name: nome,
student_program : program},
sucess: function(data){
console.log(data);
}, error: function(error){
console.log(error);
}
});
}
});

I change it for :

frappe.ui.form.on(“Program Enrollment”, “on_submit”, function(frm) {
$.ajax({
url : “http://www.mundiallanguages.com/services/sendEmail.php”,
dataType: ‘text’,
type: ‘POST’,
contentType: ‘application/x-www-form-urlencoded; charset=utf-8’,
data : {student_name: frm.doc.student_name,
student_program : frm.doc.student_program},
sucess: function(data){
console.log(data);
}, error: function(error){
console.log(error);
}
});
});

But it still not working.
Could some one help me with this, it’s very important.

Maybe because of this typo?

Better use frappe ajax