AllToolKits.com Posted October 22, 2015 Report Share Posted October 22, 2015 Hi, I am developing a blesta plugin. I have country drop down, on each country select state drop down should load corresponding states. Jquery Code: $( "#country" ).change(function() { var value = $( "#country" ).val(); $.post( url + "plugin/name/admin_did/get_states", { country_id: value }) .done(function( data ) { alert( "Data Loaded: " + data ); }); }); Controller public function get_states() { $c_id = $this->post['country_id']; $states = $this->Country->getList($c_id); echo json_encode($states); exit; } But got error Data Loaded: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us" dir="ltr"> <head> <title>Blesta</title> <link rel="stylesheet" type="text/css" href="/app/views/errors/css/styles.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <div class="program_error"> <h3>Oh noes!</h3> <div class="contents"> <p>Files does not exist: C:\pathofplugin\views\admin\default\message.pdt on line <strong>120</strong> in <strong> What is wrong with this ajax call approch? Quote Link to comment Share on other sites More sharing options...
0 Tyson Posted October 22, 2015 Report Share Posted October 22, 2015 A few things: The method "get_states" should be "getStates" If you're using CSRF tokens (enabled by default), you must pass the CSRF token in the POST request as well, or the request will be denied. I don't see any reason you can't use a GET request instead. The error is in regards to setting a message via setMessage or flashMessage. If you are calling either of these methods, you should pass additional parameters to these methods that indicate the message view is not from your plugin, but from Blesta core instead. You might take a look at the admin_clients_add.pdt template for an example of fetching states, and use the blestaRequest function for your request instead. Michael 1 Quote Link to comment Share on other sites More sharing options...
0 Blesta Addons Posted October 22, 2015 Report Share Posted October 22, 2015 If you're using CSRF tokens (enabled by default), you must pass the CSRF token in the POST request as well, or the request will be denied. I don't see any reason you can't use a GET request instead. i believe that is the main reason for that error , try using get instead of post . PauloV 1 Quote Link to comment Share on other sites More sharing options...
Question
AllToolKits.com
Hi,
I am developing a blesta plugin.
I have country drop down, on each country select state drop down should load corresponding states.
Jquery Code:
Controller
But got error
Data Loaded: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us" dir="ltr">
<head>
<title>Blesta</title>
<link rel="stylesheet" type="text/css" href="/app/views/errors/css/styles.css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div class="program_error">
<h3>Oh noes!</h3>
<div class="contents">
<p>Files does not exist: C:\pathofplugin\views\admin\default\message.pdt on line <strong>120</strong> in <strong>
What is wrong with this ajax call approch?
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.