开发者

Can I pass my form values through jQuery .load() and make them readable by PHP $_POST?

Can I pass form values in load() function开发者_StackOverflow of jQuery then be able to read them as $_POST parameters in php? ...


Sure, add an object with the values as 2nd parameter to your load call. See the docs where is stated:

The POST method is used if data is provided as an object; otherwise, GET is assumed.

So your JavaScript could look like:

$('#result').load('ajax/call.php', { postVarName: 'value' }, function() {
  alert('Load was performed.');
});

In PHP you can now access it:

echo $_POST["postVarName"]; // will echo: value
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜