I'm trying to autofill a textbox (Customername, CustomerAddress, customerMobileno) when a dropdownlist(customerid) is selected.The customer Id is selected successsfully but something is going wrong when the controller action is fetched. I'm getting 404 error.I would like to mention that I'm using prettyurl as told here - Yii2. Access to higher level folder.
In firebug I'm getting the following error-
GET http://localhost:8080/amitopticals/debug/default/toolbar?tag=57a4b1623a201
200 OK
90ms
create (line 545)
GET http://localhost:8080/amitopticals/orders/orders/....php?r=orders/customer/get-for-customer&custid=2
404 Not Found
10ms
jquery.js (line 9175)
ParamsHeadersResponseHTMLCookies
<?xml version="1.0" encoding="UTF-8"?>
<!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" lang="en" xml:lang="en">
<head>
<title>Object not found!</title>
<link rev="made" href="mailto:postmaster#localhost" />
<style type="text/css"><!--/*--><![CDATA[/*><!--*/
body { color: #000000; background-color: #FFFFFF; }
a:link { color: #0000CC; }
p, address {margin-left: 3em;}
span {font-size: smaller;}
/*]]>*/--></style>
</head>
<body>
<h1>Object not found!</h1>
<p>
The requested URL was not found on this server.
The link on the
<a href="http://localhost:8080/amitopticals/orders/orders/create">referring
page</a> seems to be wrong or outdated. Please inform the author of
that page
about the error.
</p>
<p>
If you think this is a server error, please contact
the webmaster.
</p>
<h2>Error 404</h2>
<address>
localhost<br />
<span>Apache/2.4.16 (Win32) OpenSSL/1.0.1p PHP/5.6.12</span>
</address>
</body>
</html>
Code of my select2 widget and related javascript -
<?= $form->field($model, 'o_customerid')->widget(Select2::classname(), [
'data' => ArrayHelper::map(Customer::find()->all(),'c_id','customerDetails'),
'language' => 'en',
'options' => ['placeholder' => 'Select Customer Details', 'id' => 'custid'],
'pluginOptions' => [
'allowClear' => true
],
]);
?>
<?php
$script = <<< JS
$('#custid').change(function(){
var custid = $(this).val();
$.get('index.php?r=orders/customer/get-for-customer',{ custid : custid }, function(data){
alert(data);
var data = $.parseJSON(data);
$('#orders-o_customername').attr('value',data.c_name);
$('#orders-o_customeraddress').attr('value',data.c_address);
$('#orders-o_customermobno').attr('value',data.c_mobileno);
});
});
JS;
$this->registerJs($script);
?>
Controller Action in CustomerController -
public function actionGetForCustomer($custid)
{
$customer = Customer::find()->where(['c_id'=>$custid])->asArray()->one();
echo Json::encode($customer);
}
If you use pretty url your resulting url should be
://localhost:8080/amitopticals/orders/customer/get-for-customer?custid=2
instead of the resulting in you message header
://localhost:8080/amitopticals/orders/orders/....php?r=orders/customer/get-for-customer&custid=2
SO for you $get instead of
$.get('index.php?r=orders/customer/get-for-customer',{ custid : custid }, function(data){
alert(data);
........
You should use
$.get('customer/get-for-customer',{ custid : custid }, function(data){
alert(data);
Related
After several hours of research on google, I have not managed to find a tutorial that shows how to use vue.js to display the result of a sql query (for example SELECT in my case). I come to you because i need to know how i can retrieve and display the data back by the spring findAll () method in an html page with framwork vue.js.
Thank you in advance for your help.
Here is the html file in which I would like to display the data:
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>List of school</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<div id="test">
<h1>Result</h1>
<tr>
<td/>ID</td>
<td/>Description</td>
</tr>
<tr v-for="item in panier">
<td>{item.id}</td>
<td>{item.description}</td>
</tr>
</div>
<script src="http://cdn.jsdelivr.net/vue/1.0.10/vue.min.js"></script>
<script>
new Vue({
el: '#test',
data: {
panier: [
{ id: "1", description: "University"},
{ id: "2", description: "high school"}
],
}
});
</script>
</body>
</html>
The problem I do not know how to fill my basket with the data returned by the findAll () method of spring.I specify that this method returns me the data in JSON format. Like this :
{
id:1,
description:"University"
}
{
id:,
description:"University"
}
Here is my getAllType method :
#RequestMapping(value= "/getAllTypes", method = RequestMethod.GET)
public #ResponseBody Collection<Type> getAllTypes() {
return this.typeService.getAllTypes();
}
Please if possible with an example of how I should proceed.
I've got an angularjs view that I'm trying to print its results and even though the indexing and console output show the data I can't get it to show up in the actual page.
My console output of the json data received:
[Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object]
0: Object
$$hashKey: "004"
_id: Object
$oid: "527994c48776385b2e4a6e78"
__proto__: Object
author: "Undefined author"
content: "Undefined content"
title: "stfu"
__proto__: Object
1: Object
$$hashKey: "005"
_id: Object
$oid: "52799b0a8776385c490cd268"
__proto__: Object
author: "adam-stokes"
content: "some content here"
title: "dieeeee"
My controller code:
'use strict';
var cagewebControllers = angular.module('cagewebControllers', []);
cagewebControllers.controller('IndexCtrl', ['$scope', '$http',
function($scope, $http) {
$http.get('http://localhost:9000/entity/page').
success(function(data, status, headers, config) {
$scope.pages = data;
console.log($scope.pages);
});
}
]);
My app code:
'use strict';
var cageweb = angular.module('cageweb', [
'ngRoute',
'cagewebControllers'
]);
cageweb.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
» when('/', {
» templateUrl: 'partials/index',
» controller: 'IndexCtrl'
» }).
» otherwise({
» redirectTo: '/'
» });
}]);
my template partial:
<h1>Pages</h1>
{{pages.length}}
<div ng-repeat="page in pages track by $id(page)">
page {{$$hashKey}} - {{page.title}}
</div>
my template layout:
<!DOCTYPE html>
<html ng-app="cageweb">
<head>
<title>{{ title }}</title>
<link rel='stylesheet' href='/stylesheets/style.css' />
<script src="javascripts/lib/jquery/jquery-1.10.2.min.js"></script>
<script src="javascripts/lib/angular/angular.js"></script>
<script src="javascripts/lib/angular/angular-animate.min.js"></script>
<script src="javascripts/lib/angular/angular-resource.min.js"></script>
<script src="javascripts/lib/angular/angular-route.min.js"></script>
<script src="javascripts/app.js"></script>
<script src="javascripts/controllers.js"></script>
</head>
<body>
<h1>cage-webbbbb</h1>
<div class="view-container">
<div ng-view class="view-frame"></div>
</div>
</body>
</html>
$scope.pages does contain the json data and I can see the data with console.log($scope.pages) but for whatever reason I can not get it to print on the page itself. im not sure if its something easy im missing but a second set of eyes would be much appreciated.
thanks
Thanks to the comments I was able to narrow down my issue. I probably should've mentioned that the application server was nodejs with expressjs using hogan as the templating engine...and guess what, hogan uses the same syntax as angular for processing variables :\ once I switched to ejs I was able to print to the page.
thanks!
This php file appears correct, but is returning an 'unexpected end of file' error. Is the error somewhere in the html file. I have tried putting the tags inside print in "", removed one extra white space on the php line, added white spaces between the brackets[] and quotes'' on the variable lines, and still have the same error when I press enter to send the data to the php script. Here is the html code: http://pastebin.com/Rb62pZcy
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Your Feedback</title>
</head>
<body>
<?php // Script 3.3 handle_form.php
// This page receives the data from feedback.html
// It will receive: title, name, email, comments in $_POST
$title = $_POST [ 'title' ] ;
$name = $_POST [ 'name' ] ;
$email = $_POST [ 'email' ] ;
$comments = $_POST [ 'comments' ] ;
print "<p>Thank you, $title $name, for your comments.</p>"
"<p>You stated that you found this example to be '$response' and added:<br />$comments</p>"
?>
</body>
Instead of this:
print "<p>Thank you, $title $name, for your comments.</p>"
"<p>You stated that you found this example to be '$response' and added:<br />$comments</p>"
Use this:
echo "<p>Thank you, $title $name, for your comments.</p>";
echo "<p>You stated that you found this example to be '$response' and added:<br />$comments</p>";
I think you miss the ";" character.
------------------UPDATE-----------------------------
I try this code and works:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Your Feedback</title>
</head>
<body>
<?php
if (isset($_POST['email'])){
$title = $_POST['title'];
$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];
}
else
{
$title = "No title arrived";
$name = "No name arrived";
$comments = "No comments arrived";
}
//$response is not defined??
$response = "Live long and prosper";
//so i defined
echo "<p>Thank you, $title $name, for your comments.</p>";
echo "<p>You stated that you found this example to be '$response' and added:<br />$comments</p>";
?>
</body>
</html>
PS: try executing this script alone...name it "handle_form.php" and put this in the nav address bar:
localhost/your_project/handle_form.php
Works on my localhost.....if your problem continue then may be the problem is in the submit page.
Saludos.
I am trying to send innerhtml of a particular div to email(in Codeigniter framework).
I got the inner html of the div using jquery and transfered the data to the controller using ajax.
The mail worked, but my problem is html classes, style tags(except the inline styles i wrote in the view file html), style sheet are not working.
Is there any way to add my style.css file in the email content? I will be ok even if the tag works properly, which I had put at the begining of the <head> section.
Please help, here is my code.
Ajax code for transfering html to controller:
<script type="text/javascript">
$(function() {
$('#sendmail').click(function(e) {
e.preventDefault();
$.ajax({
url:'<?php echo site_url();?>/welcome/send',
type:'POST',
data:{'message':$('#body').html(),'subject':'Subject of your e-mail'},
success:function(data) {
alert('You data has been successfully e-mailed');
alert('Your server-side script said: ' + data);
}
});
});
});
</script>
Code in the controller
public function send()
{
$nome = $this->input->post('message');
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'send.one.com',
'smtp_port' => '2525',
'smtp_user' => 'akhil.ns#cymose-tech.com',
'smtp_pass' => 'akhil123',
'charset' => 'utf-8',
'wordwrap' => TRUE,
'mailtype' => 'html'
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('akhil.ns#cymose-tech.com', 'The Wanderers');
$this->email->to('shabasy002#gmail.com');
$this->email->subject('The Wanderers Proforma Invoice ');
$formatedMessag ='';
$formatedMessag = '<html><head><link rel="stylesheet" type="text/css" href="http://localhost/study/extra/style.css"></head><body><style type="text/css">p{color:#cccccc;font-weight:bold;}</style>';
$formatedMessag .= $nome.'</body></html>';
$this->email->message($formatedMessag);
if ($this->email->send()) {
echo $formatedMessag;
}
}
As far as I know, no email clients allow loading of external stylesheets for HTML emails.
Ultimately, this means that you have to declare the styles in the head of the document, e.g.
<head>
<style>
body { background: black; color: white; }
</style>
</head>
However, some email clients (Well, pretty much just outlook) don't even allow some styles defined in the head of the document, which means inlining styles like such:
<body style="background: black; color: white;"></body>
(a little bit of me inside just died)
There are also a number of problems with using even inline CSS in HTML emails as some clients (again mostly outlook) don't support simple CSS features like float's. Which ends up meaning you have to code the newsletter with tables to ensure it works for the majority of people.
For more information see this article (or just Google around):
http://www.sitepoint.com/code-html-email-newsletters/
The problem, actually is that you can use only inline and internal css, that means, you can define all the css rules right inside the element like
<td style="padding:10px;"><b style="color:red;">Texty</b></td>
or in the <head></head> part of your email document:
<head>
<style>
b {color:red;}
td { padding:10px; }
</style>
</head>
I'm using lighhtpd with php. Work with Zend Framework.
I put a simple page test.html with only HTML code. When I try to see it, I get an error:
Invalid controller specified (test.html): /test.html
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div>TODO write content</div>
</body>
</html>
On my conf (not htaccess)
url.rewrite-once = (
".*\?(.*)$" => "/index.php?$1",
".*\.(js|ico|gif|jpg|png|css)$" => "$0",
"" => "/index.php"
)
I'm lost. Try several option and not understand the problem.
Well.
Apologize for question.
Simple.
url.rewrite-once = (".*\?(.*)$" => "/index.php?$1",".*\.(js|ico|gif|jpg|png|css)$" => "$0","" => "/index.php")
Changed to
url.rewrite-once = (".*\?(.*)$" => "/index.php?$1",".*\(js|ico|gif|jpg|png|css|html)$" => "$0","" => "/index.php")