Search Posts

Category: post

Angularjs POST method returns 404 error in console

I am trying to write the data with the POST method through api on: http://localhost:4567/api/v1/companies. I have tried various things from the stack, This is my code: <head> <script src=””></script> <script src=””></script> <script> var app = angular.module(“app”, []); app.controller(“HttpGetController”, function ($scope, $http) { $scope.SendData = function () { // use $.param jQuery function to serialize data from JSON var data = $.param({ id: $, name: $, city: $, }); var config = { headers : […]

contact form using php in angularjs

html : View/contactform.html <form method=”post” role=”form” name=”myemailform” action=”sendingemail.php”> <div class=”form-group”> <input type=”text” name=”name” class=”form-control” id=”name” placeholder=”Your Name” data-rule=”minlen:4″ data-msg=”Please enter at least 4 chars” /> <div class=”validation”></div> </div> <div class=”form-group”> <input type=”email” class=”form-control” name=”email” id=”email” placeholder=”Your Email” data-rule=”email” data-msg=”Please enter a valid email” /> <div class=”validation”></div> </div> <div class=”form-group”> <input type=”text” class=”form-control” name=”subject” id=”subject” placeholder=”Subject” data-rule=”minlen:4″ data-msg=”Please enter at least 8 chars of subject” /> <div class=”validation”></div> </div> <div class=”form-group”> <textarea class=”form-control” name=”message” rows=”5″ cols=”10″ […]

AngularJS restangular post callback

I am using restangular with AngularJS, and I need to use some function, which will trigger callback function/promise after POST response. I tryed setResponseInterceptor which did not helped in this situation. I need to use this function to lock form from submission until response will come back to client, and then unlock it to future use. Do you know some magic for this? I am using this code, and want to fire custom function when […]

AngularJS Upload image sending post through $http function

I recently tried to code an upload script which is not really working as it should. The goal is to send a Picture through POST method, using the $http function built in AngularJS. So I’m basically using AngularJS to get datas from my own API REST and insert them to the dom, my front server and my back server are separated. But as i want to upload my files directly on the front server, where […]

Posting form with AngularJS returns 405 code, after publishing website

I’m having an issue when I post data from a form to server I receive: angular.js:14642 Possibly unhandled rejection: {“data”:”<html>n<head><title>405 Not Allowed</title></head>n<body bgcolor=”white”>n<center><h1>405 Not Allowed</h1></center>n</body>n</html>”,”status”:405,”config”:{“method”:”POST”,”transformRequest”:[null],”transformResponse”:[null],”jsonpCallbackParam”:”callback”,”url”:”/messages”,”headers”:{“Accept”:”application/json, text/plain, */*”}},”statusText”:”Method Not Allowed”} Everything works normal on localhost, but after publishing i receive this error on post. My website is published on Github pages and the domain is namecheap. Here is my route code: module.exports = (function() { ‘use strict’; var router = require(‘express’).Router(); var Message = require(‘./angular/models/messageModel’);‘/messages’, […]

Nodejs callback response not working as expected

I’m trying to authenticate a user based on values entered in a given form. However, after using res.send(), the function at AngularJS controller is not able to correctly redirect user even if the password and username are correct. Am I handling the callbacks correctly? Controller <script> var app = angular.module(‘myApp’, []); app.controller(“loginController”, function($scope,$http) { $scope.sub = function() { var config = { headers : { ‘Content-Type’: ‘application/x-www-form- urlencoded;charset=utf-8;’ } } $‘/login’, { data:{ username: $scope.username, […]

Nodejs Express redirecting does not work

I’m currently trying to redirect a user to a success screen after he click the login button. Everything seems to be working fine but the page does not change. Tried searching online but none of the solution helped. Update It seems that the root cause is because of ‘/’ in routes. Changed it to ‘/home’ and it works now Solved Below is my html, server and route codes index.html <!DOCTYPE html> <html> <head> <script src=””> […]