donglin9717 2012-09-24 16:35
浏览 87
已采纳

在jquery代码之后调用PHP函数

Dear Firends I have large number of forms on a single web page all of them calls a single PHP function. However what I want is that the forms should call a jquery function and if there is a need then jquery should let it call the PHP function.

I do not want to use Ajax just want to create a PHP function call if the matter can not be solved by jquery.

Each of the form is associated with some data. how ever all the data that is displayed on the page is not available all the time. So what I want is

 if (data == available)   { call PHP}
 elseif (data != available) { jquery alert('sory bro');}

if data can not be seen now just use jquery to say sorry (no need to check from server). When a page is loaded we know which all pieces of data can not bee seen and are given in different color.

The forms are generated using a PHP loop with each form showing different data but of same type (each form is assocaited with a sort of Article).

All the questions that I have seen are about Ajax. Where as my current PHP code is working fine. all I want it that before making a trip to server if the data is not available the jquery shoould say so. We already know which data is not avaiable so far.

I hope I have explained it

Thanks a lot

**I think I have not made my point clear.. When the page is loaded is already know which data is not available for display and it is marked in seperate color and the div has different arrtibute...*is there some way so that I do not call PHP function for those forms?

  • 写回答

3条回答 默认 最新

  • dspvin19712 2012-09-24 16:38
    关注

    PHP executes on the server side. Javascript (jQuery) executes on the client-side. So PHP is completely done executing before Javascript starts executing.

    That's why everyone is saying you need to use AJAX. AJAX is a way to make a call back to the server in order to execute PHP code. PHP code only executes on the server. So in order to execute PHP, you have to make a call back to the server.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据