Reputation: 1067
When i click on Call my webservice button its id="click-me-web-service" then the ajax request send and call my file hit-web-service.php but i found error on this stage help me to solve it. Is my method correct to call the php file?
jQuery(document).ready(function() {
jQuery("#click-me-web-service").click(function() {
jQuery.ajax({
type: "POST",
url: "{$base_dir}modules/wrd_web_service/hit-web-service.php",
data: { first_name: "Joh", last_name: "Sin", username: "johsin", email: "[email protected]" },
success: function() {
console.log("Success.");
}
});
})
});
Upvotes: 0
Views: 771
Reputation: 171
please be careful when using js codes inside smarty templates. The use braces {}
inside tpl may conflict, when you want real braces in your js use {literal}
please modify your code as below
{literal}
jQuery(document).ready(function() {
jQuery("#click-me-web-service").click(function() {
jQuery.ajax({
type: "POST",
url: "{/literal}{$base_dir}{literal}modules/wrd_web_service/hit-web-service.php",
data: { first_name: "Joh", last_name: "Sin", username: "johsin", email: "[email protected]" },
success: function() {
console.log("Success.");
}
});
})
});
{/literal}
Upvotes: 1