开发者

can't get results form php

I develop a select form and used ajax to call the php script to get the results, the ajax works fine and successful connected to the php, but I couldn't get the results form the php

this is my form:

<form method="post" action = "#">
  <div class="functionitem" id="selector_phot">
    <select name="photographer">
       <option>All Photographers</option>
      <option>John Baldwin</option>
      <option>Wendy James</option>
      <option>Ian Smith</option>
      <option>Rebecca Fortesque-Smythe</option>
    </select>
  </div>
  <div class="functionitem" id="selector_cat">
    <select name="sets">
      <option>All Sets</option>
      <option>Ceremony</option>
      <option>Lunch</option>
      <option>Garden</option>
    </select>
  </div>

  <div class="functionitem" id="viewresult"><span class="button"><span><input type="button" class="form_button" value="  View"></span></span>
   </div>


   <div class="functionitem" style="margin-right: 60px">
   <span class="button"><span><input type="button" class="form_button" id="guestlogin" value="  Guest Login  "></span></span>
   </div>

   <div class="functionitem">
   <span class="button"><span><input type="button" class="form_button" id="register" value="  Register"></span></span>
   </div>

Here is my php script:

   if(is开发者_如何学编程set($_POST['photographer'])&&isset($_POST['sets']))
  {

        echo "results";

 }

so it should print out the results, but it didn't what did I do wrong, please help, thanks!

here is the ajax code:


You're calling serialize on this, which is an input tag.

You need to call serialize on the form

$('form').serialize();

Note: if you have multiple forms, it will serialize all the forms together. Give it an id if that's the case and use the id as a selector

Or you can also do this:

$(this).closest('form').serialize();

(Which will go upward in the dom from your button until it finds a form)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜