javascript - Calling a php function with ajax -


Hi I'm using AJAX to post requests. I think what I want to do is call the function within a php file, but if you do this then there is a bit confused, can someone put any light on it? This is in my JS file:

  function callAjaxAddition2 () {arguments0 = jQuery ('# code'). Val (); $ AJAX ({type: "POST", "url: file.php", data: {code: arguments0}, success: function (data) {request ($ post)}}); Return return;}   

Update I think that I should be able to trigger the need to use it: if the 'request' is a function within a php file. I put the URL in the Url field, but it does not seem to work, how can I use a callback with Ajax Post?

Post-text "itemprop =" text ">

Fix this row with the wrong opening quote file.php" .

You can not call a PHP function via AJAX, but can trigger when it should be called, then the following shows:

In PHP, your code will be:

  if (isset ($ _ POST ['code'])) {# 'code' passed here by AJAX request ($ _ POST ['code'] Is the identifier;}  

Once your function has been called, is required and returns the output to AJAX, you can use the data parameter You have seen that What was the output sent back from PHP:

  Success: Function (data) {Alert (data); // contains the data from the // PHP file after the execution of the function} / Code> 

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -