php - Is it possible to update a database with jquery in Symfony2? -


मैंने jsrouting-bundle स्थापित किया है, और यह मेरा कोड है:

जावास्क्रिप्ट:

  $ (दस्तावेज़) .ready (function () {$ ("pmcontents")। Hide (); $ ("। Pmbox")। क्लिक करें (फ़ंक्शन () {$ (This)। सीएसएस ("फ़ॉन्ट-वजन", "सामान्य"), $ (यह) .next ()। टॉगल (); var myValue = $ ('this')। Attr ('id'); var डेटा = 'भेजावाले =' + myValue; $। एजेक्स ({प्रकार: "पोस्ट", यूआरएल: रूटिंगिंग। ('आइडाइड'), डेटा: डेटा, कैश: गलत, सफलता: फ़ंक्शन (डेटा) {अलर्ट ("डेटाबेस अद्यतन किया गया है");              }         });     });  });  

नियंत्रक:

  सार्वजनिक फ़ंक्शन isreadAction () {$ request = $ this- & gt; प्राप्त करें ('अनुरोध') ; यदि ($ request- & gt; isXmlHttpRequest ()) {var_dump ($ अनुरोध- & amp;; अनुरोध- & gt; प्राप्त करें ('sentValue')); $ Em = $ this- & gt; getDoctrine () - & gt; getEntityManager (); $ Pm = $ this- & gt; getDoctrine () - & gt; getRepository ('लॉग इन लॉगिन बंडल: निजी संदेश)' - & gt; FindBypmid ($ अनुरोध- & amp;; अनुरोध- & gt; प्राप्त करें ('sentValue')); $ बजे & gt; setIsRead (सही); $ Em- & gt; फ्लश (); नया रिटर्न () लौटें; }}  

रूटिंग:

  isread: path: / game / isread डिफ़ॉल्ट: {_controller: LoginLoginBundle: Default: isread } आवश्यकताओं: _method: POST  

लेकिन यह is_read कॉलम को अपडेट करने के लिए काम नहीं करता है। इसके अलावा मुझे अपने विक्रेता फ़ोल्डर में त्रुटियां मिलती हैं:

त्रुटियाँ

आप एजेक्स के साथ ऐसा कर सकते हैं

  $। Ajax ({type: "POST", / / Routing.generate = install fosjsroutingbundle url: routing.generate ('the_route_of_your_contoller'), डेटा: डेटा, कैश: गलत, सफलता: कार्य (डेटा) {चेतावनी ("डेटाबेस अद्यतन किया गया है");}});  

और नियंत्रक में दृढ़ता / अद्यतन की भूमिका होगी


मार्ग, सामान्य रूप में समान बस आवश्यकताओं को जोड़ें:

  पथ: / .. डिफ़ॉल्ट: {_controller: ..: ..: ..} आवश्यकताएं: _method: POST  

प्रतिक्रिया

<पूर्व> वापस नए रिस्पांस ();

अपनी फ़ाइल के शीर्ष पर


2

>

मुझे ऐसा करना चाहिए:

jquery:

  var myValue = $ ('this')। Attr ('id'); // पोस्ट एजेक्स var डेटा = 'भेजावाले =' + myValue; नियंत्रक में  

  $ अनुरोध = $ this- & gt; प्राप्त करें ('अनुरोध'); अगर ($ request- & gt; isXmlHttpRequest ()) {$ value = $ request- & gt; अनुरोध- & gt; प्राप्त करें ('sentValue');  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -