I have solved the problem. The solution I found somewhere on the web.
In all the other suggestion they were suggesting to add switch context as below:
$contextSwitch=$this->_helper->getHelper("contextSwitch");
$contextSwitch->addActionContext("addnewcustomer","html");
$contextSwitch->initContext();
But I didn't add the view file, which was suppose to be:
addcustomer.html.phtml
That is why the error 404 was showing.
But after I had added the file new error 500 was showing. After searching two days finally I found a solution. The problem was, xml or json get accepted easily but html context, probably, does not exists. So needed to be created before added. Here is the complete added code:
$contextSwitch=$this->_helper->getHelper("contextSwitch");
$contextSwitch->setContext('html', array('suffix'=> 'html','headers'=> array('Content-Type' => 'text/html; Charset=UTF-8',),));
$contextSwitch->addActionContext("addnewcustomer","html");
$contextSwitch->initContext();
and the required view file is
addnewcustomer.phtml
the problem solved right away