I’m having a form and using the $.POST for posting it to the some url..
From there i couldn’t access the form values. I dont know what the error may be??
The form is like
<form id="registration-form" >
<input type="hidden" name="Profile[fb_uid]" value='1232323'></input>"
<select name="Profile[feet]" id="feet">
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
<a class="btnLgBlueGrad" href="#" name="closeModal" id="profileSubmit">Start</a>
</form>
the js call is like this
$( "#profileSubmit" ).click(function() {
$.post("?r=site/addBasicProfile",
function(data){
alert(data); // this is alerting as empty
if(data==1)
window.location.href="?r=site/index";
});
});
The actual method which is called is
public function actionAddBasicProfile(){
echo $_REQUEST['profile'];
// when i echo something static it is reflected in the ajax callback function
}
I’m sure the url is correct and ajax request is passed.
That’s because you don’t pass any data to the $.post(), from the jquery website:
So you should pass some data to your php script:
And as a side note you should use
$_POSTto get POST values since$_REQUESTcan also get you the GET values.