scrollTo无效

时间:2015-12-30 05:53:35

标签: javascript jquery

我正在创建一个表单它工作正常,我有一个问题,当用户没有填写一个字段意味着我想显示错误消息,错误消息也工作但我想显示特定字段所以我使用scrollTo函数但它没有移动......

$(document).ready(function() {
  $("#btn-submit").click(function() {
    if ($('#FranchiseeForm').valid()) {
      //alert("Sucess");
      $.ajax({
        type: "POST",
        url: "php/register-check.php",
        data: $('form#FranchiseeForm').serialize(),
        success: function(data) {
          var result = data["response"];
          console.log(result);
          if (result == 'success') {
            $('body').animate({
              scrollTop: $('#email_success')
            }); //This one working for me
            $('#email_success').fadeOut(3000);
            $(".panel-title").hide();
            $("#email_success").show();
            $('#fname').val("");
            $('#lname').val("");
            $('#email').val("");
            $('#mobile').val("");
            $('#address').val("");
            $('#countryId').val("");
            $('#stateId').val("");
            $('#cityId').val("");
            $('#pincode').val("");
            $('#capital').val("");
            $('#timeframe').val("");
            $('#location').val("");
          } else {
            $("#email_error").show();
          }
        },
      });
      return false;
    } else {
      $('body').animate({
        scrollTo: $('#address')
      }); //this code not working for me,
    }
  });
});

1 个答案:

答案 0 :(得分:0)

Time Awake Since Boot: 1500 seconds System Integrity Protection: enabled Crashed Thread: 19 com.apple.PepperUICore.Blur Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000028 Exception Note: EXC_CORPSE_NOTIFY VM Regions Near 0x28: --> __TEXT 0000000000087000-0000000000312000 [ 2604K] r-x/rwx SM=COW /Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator.sdk/System/Library/CoreServices/Carousel.app/Carousel Application Specific Information: CoreSimulator 201.3 - Device: Apple Watch - 42mm - Runtime: watchOS 2.1 (13S660) - DeviceType: Apple Watch - 42mm Thread 0:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x07602886 semaphore_wait_trap + 10 1 libdispatch.dylib 0x072987f8 _dispatch_semaphore_wait_slow + 298 2 libdispatch.dylib 0x072986c5 dispatch_semaphore_wait + 37 3 com.apple.PepperUICore 0x042b20b6 _PUICBlurApply + 456 4 com.apple.PepperUICore 0x042b2723 PUICBlurApply + 24 5 com.apple.CarouselUIServices 0x039a7fab -[CUISAlertPlatterView updateBlurWithContext:] + 885 6 com.apple.CarouselUIServices 0x039a7c26 -[CUISAlertPlatterView updateBlurIfNeeded] + 129 7 com.apple.CarouselUIServices 0x039a7a19 -[CUISAlertPlatterView didMoveToWindow] + 68 8 com.apple.UIKit 0x04bf6fae -[UIView(Internal) _didMoveFromWindow:toWindow:] + 2053 9 com.apple.UIKit 0x04bf6b83 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 986 10 com.apple.UIKit 0x04bf6b83 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 986 11 com.apple.UIKit 0x04bf6b83 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 986 12 com.apple.UIKit 0x04c0dc3a -[UIScrollView _didMoveFromWindow:toWindow:] + 85 13 com.apple.UIKit 0x04bf6b83 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 986 14 com.apple.UIKit 0x04bea9bc __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 180 15 com.apple.UIKit 0x04bea894 -[UIView(Hierarchy) _postMovedFromSuperview:] + 489 16 com.apple.UIKit 0x04bf9f64 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 2307 17 com.apple.UIKit 0x04be8893 -[UIView(Hierarchy) addSubview:] + 56 18 com.apple.Carousel 0x000f545e 0x87000 + 451678 19 com.apple.Carousel 0x0017b963 0x87000 + 1001827 20 com.apple.Carousel 0x00222373 0x87000 + 1684339 21 com.apple.Carousel 0x001b9254 0x87000 + 1253972 22 com.apple.Carousel 0x001e405f 0x87000 + 1429599 23 com.apple.BaseBoard 0x023e19a0 __22-[BSTransaction begin]_block_invoke + 115 24 com.apple.BaseBoard 0x023e63a3 -[BSTransaction _preventTransactionCompletionForReason:ignoringAuditHistory:andExecuteBlock:] + 64 25 com.apple.BaseBoard 0x023e18c7 -[BSTransaction begin] + 873 26 com.apple.Carousel 0x000f4616 0x87000 + 448022 27 com.apple.Carousel 0x000f3b1e 0x87000 + 445214 28 com.apple.BaseBoard 0x023f2df1 -[BSEventQueueEvent _execute] + 43 29 com.apple.BaseBoard 0x023f2dc1 -[BSEventQueueEvent executeFromEventQueue] + 33 30 com.apple.BaseBoard 0x023eac29 -[BSEventQueue _processNextEvent] + 354 31 com.apple.BaseBoard 0x023ea0d2 -[BSEventQueue _executeOrPendEvents:position:] + 954 32 com.apple.BaseBoard 0x023ea183 -[BSEventQueue executeOrInsertEvents:atPosition:] + 48 33 com.apple.BaseBoard 0x023ea14b -[BSEventQueue executeOrInsertEvent:atPosition:] + 92 34 com.apple.Carousel 0x000f3174 0x87000 + 442740 35 com.apple.Carousel 0x000d59f0 0x87000 + 322032 36 com.apple.Carousel 0x000d58ee 0x87000 + 321774 37 com.apple.Carousel 0x001c4908 0x87000 + 1300744 38 com.apple.Carousel 0x001c4656 0x87000 + 1300054 39 com.apple.BaseBoard 0x023e19a0 __22-[BSTransaction begin]_block_invoke + 115 40 com.apple.BaseBoard 0x023e63a3 -[BSTransaction _preventTransactionCompletionForReason:ignoringAuditHistory:andExecuteBlock:] + 64 41 com.apple.BaseBoard 0x023e18c7 -[BSTransaction begin] + 873 42 com.apple.Carousel 0x001f559d 0x87000 + 1500573 43 com.apple.Carousel 0x001f7fdd 0x87000 + 1511389 44 com.apple.BaseBoard 0x023f2df1 -[BSEventQueueEvent _execute] + 43 45 com.apple.BaseBoard 0x023f2dc1 -[BSEventQueueEvent executeFromEventQueue] + 33 46 com.apple.BaseBoard 0x023eac29 -[BSEventQueue _processNextEvent] + 354 47 com.apple.BaseBoard 0x023eae01 -[BSEventQueue _removeEventQueueLock:] + 145 48 com.apple.BaseBoard 0x023e72e2 -[BSEventQueueLock relinquish] + 62 49 com.apple.Carousel 0x001f55c8 0x87000 + 1500616 50 com.apple.Carousel 0x001fe671 0x87000 + 1537649 51 libdispatch.dylib 0x0728f72b _dispatch_call_block_and_release + 15 52 libdispatch.dylib 0x072ad40d _dispatch_client_callout + 14 53 libdispatch.dylib 0x07295fce _dispatch_main_queue_callback_4CF + 689 54 com.apple.CoreFoundation 0x0662db3e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14 55 com.apple.CoreFoundation 0x065eb864 __CFRunLoopRun + 2356 56 com.apple.CoreFoundation 0x065eac76 CFRunLoopRunSpecific + 470 57 com.apple.CoreFoundation 0x065eaa8b CFRunLoopRunInMode + 123 58 com.apple.GraphicsServices 0x04af2097 GSEventRunModal + 192 59 com.apple.GraphicsServices 0x04af1ed4 GSEventRun + 104 60 com.apple.UIKit 0x04b39e96 UIApplicationMain + 160 61 com.apple.Carousel 0x00141872 0x87000 + 764018 62 libdyld.dylib 0x072d1ae1 start + 1 Thread 1:: Dispatch queue: com.apple.libdispatch-manager 0 libsystem_kernel.dylib 0x0760a7f6 kevent64 + 10 1 libdispatch.dylib 0x0729c2db _dispatch_mgr_invoke + 257 2 libdispatch.dylib 0x0729c02b _dispatch_mgr_thread + 60 Thread 2: 0 libsystem_kernel.dylib 0x0760284a mach_msg_trap + 10 1 libsystem_kernel.dylib 0x07601c34 mach_msg + 68 2 com.apple.CoreFoundation 0x065ec146 __CFRunLoopServiceMachPort + 214 3 com.apple.CoreFoundation 0x065eb526 __CFRunLoopRun + 1526 4 com.apple.CoreFoundation 0x065eac76 CFRunLoopRunSpecific + 470 5 com.apple.CoreFoundation 0x065eaa8b CFRunLoopRunInMode + 123 6 com.apple.Foundation 0x046a7601 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 308 7 com.apple.Foundation 0x0474d9cd -[NSRunLoop(NSRunLoop) run] + 82 8 com.apple.UIKit 0x051ca202 -[UIStatusBarServerThread main] + 967 9 com.apple.Foundation 0x04759e84 __NSThread__start__ + 1346 10 libsystem_pthread.dylib 0x075cfa26 _pthread_body + 138 11 libsystem_pthread.dylib 0x075cf99c _pthread_start + 155 12 libsystem_pthread.dylib 0x075ccf96 thread_start + 34 Thread 3:: com.apple.springboard.backgroundappservices 0 libsystem_kernel.dylib 0x0760284a mach_msg_trap + 10 1 libsystem_kernel.dylib 0x07601c34 mach_msg + 68 2 com.apple.CoreFoundation 0x065ec146 __CFRunLoopServiceMachPort + 214 3 com.apple.CoreFoundation 0x065eb526 __CFRunLoopRun + 1526 4 com.apple.CoreFoundation 0x065eac76 CFRunLoopRunSpecific + 470 5 com.apple.CoreFoundation 0x065eaa8b CFRunLoopRunInMode + 123 6 com.apple.Carousel 0x00129cd0 0x87000 + 666832 7 libsystem_pthread.dylib 0x075cfa26 _pthread_body + 138 8 libsystem_pthread.dylib 0x075cf99c _pthread_start + 155 9 libsystem_pthread.dylib 0x075ccf96 thread_start + 34 Thread 4:: com.apple.springboard.icongeneration 0 libsystem_kernel.dylib 0x0760284a mach_msg_trap + 10 1 libsystem_kernel.dylib 0x07601c34 mach_msg + 68 2 com.apple.CoreFoundation 0x065ec146 __CFRunLoopServiceMachPort + 214 3 com.apple.CoreFoundation 0x065eb526 __CFRunLoopRun + 1526 4 com.apple.CoreFoundation 0x065eac76 CFRunLoopRunSpecific + 470 5 com.apple.CoreFoundation 0x065eaa8b CFRunLoopRunInMode + 123 6 com.apple.Carousel 0x00129dc6 0x87000 + 667078 7 libsystem_pthread.dylib 0x075cfa26 _pthread_body + 138 8 libsystem_pthread.dylib 0x075cf99c _pthread_start + 155 9 libsystem_pthread.dylib 0x075ccf96 thread_start + 34 Thread 5: 0 libsystem_kernel.dylib 0x07609d76 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x075cf52d _pthread_wqthread + 1289 2 libsystem_pthread.dylib 0x075ccf72 start_wqthread + 34 Thread 6:: Dispatch queue: com.apple.opengl.cvmDoWork 0 libLLVMContainer.dylib 0x09bec177 llvm::LiveIntervalUnion::extract(llvm::LiveInterval&, llvm::LiveRange const&) + 343 1 libLLVMContainer.dylib 0x09bf2f7f llvm::LiveRegMatrix::unassign(llvm::LiveInterval&) + 255 2 libLLVMContainer.dylib 0x09c90c04 (anonymous namespace)::RAGreedy::evictInterference(llvm::LiveInterval&, unsigned int, llvm::SmallVectorImpl<unsigned int>&) + 532 3 libLLVMContainer.dylib 0x09c902f8 (anonymous namespace)::RAGreedy::tryEvict(llvm::LiveInterval&, llvm::AllocationOrder&, llvm::SmallVectorImpl<unsigned int>&, unsigned int) + 840 4 libLLVMContainer.dylib 0x09c8ceed (anonymous namespace)::RAGreedy::selectOrSplitImpl(llvm::LiveInterval&, llvm::SmallVectorImpl<unsigned int>&, llvm::SmallSet<unsigned int, 16u, std::__1::less<unsigned int> >&, unsigned int) + 557 5 libLLVMContainer.dylib 0x09c8bcb9 (anonymous namespace)::RAGreedy::selectOrSplit(llvm::LiveInterval&, llvm::SmallVectorImpl<unsigned int>&) + 121 6 libLLVMContainer.dylib 0x09c8bf72 non-virtual thunk to (anonymous namespace)::RAGreedy::selectOrSplit(llvm::LiveInterval&, llvm::SmallVectorImpl<unsigned int>&) + 34 7 libLLVMContainer.dylib 0x09c83ba3 llvm::RegAllocBase::allocatePhysRegs() + 195 8 libLLVMContainer.dylib 0x09c8badb (anonymous namespace)::RAGreedy::runOnMachineFunction(llvm::MachineFunction&) + 1499 9 libLLVMContainer.dylib 0x09c2311a llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 106 10 libLLVMContainer.dylib 0x0a1b3e93 llvm::FPPassManager::runOnFunction(llvm::Function&) + 595 11 libLLVMContainer.dylib 0x0a1b380a llvm::legacy::FunctionPassManagerImpl::run(llvm::Function&) + 186 12 libLLVMContainer.dylib 0x0a1b3710 llvm::legacy::FunctionPassManager::run(llvm::Function&) + 96 13 libLLVMContainer.dylib 0x09862c94 llvm::JIT::getPointerToFunction(llvm::Function*) + 180 14 libGLVMPlugin.dylib 0x18dd4b1e cvmContentBuildLLVMFunctions(_cvms_plugin_element_s const*, llvm::Function**, unsigned int) + 94 15 libGLVMPlugin.dylib 0x18dd48ff cvmsPluginElementBuild + 1039 16 libCoreVMClient.dylib 0x0973b110 cvmsCompBuildElement + 121 17 libCoreVMClient.dylib 0x0973ff5f cvmsServerElementBuild + 1002 18 libCoreVMClient.dylib 0x0973ba37 cvms_element_build_from_source + 107 19 libCVMSPluginSupport.dylib 0x09734872 cvm_deferred_build_modular(void*) + 393 20 libdispatch.dylib 0x072ad40d _dispatch_client_callout + 14 21 libdispatch.dylib 0x07295076 _dispatch_queue_drain + 1065 22 libdispatch.dylib 0x072949c1 _dispatch_queue_invoke + 563 23 libdispatch.dylib 0x072981f2 _dispatch_queue_override_invoke_owning + 32 24 libdispatch.dylib 0x072ad40d _dispatch_client_callout + 14 25 libdispatch.dylib 0x07296598 _dispatch_root_queue_drain + 744 26 libdispatch.dylib 0x072962a9 _dispatch_worker_thread3 + 108 27 libsystem_pthread.dylib 0x075cf43e _pthread_wqthread + 1050 28 libsystem_pthread.dylib 0x075ccf72 start_wqthread + 34 Thread 7: 0 libsystem_kernel.dylib 0x07609d76 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x075cf52d _pthread_wqthread + 1289 2 libsystem_pthread.dylib 0x075ccf72 start_wqthread + 34 Thread 8: 0 libsystem_kernel.dylib 0x07609d76 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x075cf52d _pthread_wqthread + 1289 2 libsystem_pthread.dylib 0x075ccf72 start_wqthread + 34 Thread 9: 0 libsystem_kernel.dylib 0x07609d76 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x075cf52d _pthread_wqthread + 1289 2 libsystem_pthread.dylib 0x075ccf72 start_wqthread + 34 Thread 10: 0 libsystem_kernel.dylib 0x07609d76 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x075cf52d _pthread_wqthread + 1289 2 libsystem_pthread.dylib 0x075ccf72 start_wqthread + 34 Thread 11: 0 libsystem_kernel.dylib 0x07609d76 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x075cf52d _pthread_wqthread + 1289 2 libsystem_pthread.dylib 0x075ccf72 start_wqthread + 34 Thread 12: 0 libsystem_kernel.dylib 0x07609d76 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x075cf52d _pthread_wqthread + 1289 2 libsystem_pthread.dylib 0x075ccf72 start_wqthread + 34 Thread 13: 0 libsystem_kernel.dylib 0x07609d76 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x075cf52d _pthread_wqthread + 1289 2 libsystem_pthread.dylib 0x075ccf72 start_wqthread + 34 Thread 14: 0 libsystem_kernel.dylib 0x0760289e semaphore_timedwait_trap + 10 1 libdispatch.dylib 0x072987a2 _dispatch_semaphore_wait_slow + 212 2 libdispatch.dylib 0x072986c5 dispatch_semaphore_wait + 37 3 libdispatch.dylib 0x07297c91 _dispatch_worker_thread + 169 4 libsystem_pthread.dylib 0x075cfa26 _pthread_body + 138 5 libsystem_pthread.dylib 0x075cf99c _pthread_start + 155 6 libsystem_pthread.dylib 0x075ccf96 thread_start + 34 Thread 15: 0 libsystem_kernel.dylib 0x07609d76 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x075cf52d _pthread_wqthread + 1289 2 libsystem_pthread.dylib 0x075ccf72 start_wqthread + 34 Thread 16: 0 libsystem_kernel.dylib 0x07609d76 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x075cf52d _pthread_wqthread + 1289 2 libsystem_pthread.dylib 0x075ccf72 start_wqthread + 34 Thread 17: 0 libsystem_kernel.dylib 0x07609d76 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x075cf52d _pthread_wqthread + 1289 2 libsystem_pthread.dylib 0x075ccf72 start_wqthread + 34 Thread 18: 0 libsystem_kernel.dylib 0x07609d76 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x075cf52d _pthread_wqthread + 1289 2 libsystem_pthread.dylib 0x075ccf72 start_wqthread + 34 Thread 19 Crashed:: com.apple.PepperUICore.Blur 0 com.apple.QuartzCore 0x040b741f -[CARenderer dealloc] + 117 1 libobjc.A.dylib 0x060fe060 objc_object::sidetable_release(bool) + 238 2 libobjc.A.dylib 0x060fd361 objc_release + 65 3 libobjc.A.dylib 0x060fd318 objc_storeStrong + 39 4 com.apple.PepperUICore 0x04223431 -[PUICLayerRenderer .cxx_destruct] + 65 5 libobjc.A.dylib 0x060e98dd object_cxxDestructFromClass(objc_object*, objc_class*) + 116 6 libobjc.A.dylib 0x060e9864 object_cxxDestruct + 20 7 libobjc.A.dylib 0x060f3cfc objc_destructInstance + 48 8 libobjc.A.dylib 0x060f3d2d object_dispose + 20 9 libobjc.A.dylib 0x060fe060 objc_object::sidetable_release(bool) + 238 10 libobjc.A.dylib 0x060fd361 objc_release + 65 11 com.apple.PepperUICore 0x042b3f21 ___PUICBlurApply_block_invoke + 3896 12 com.apple.PepperUICore 0x042b21b2 +[PUICBlurViewFactory performCABlurWorkOnBackgroundThread:] + 15 13 com.apple.Foundation 0x046a57f9 -[NSThread main] + 76 14 com.apple.Foundation 0x04759e84 __NSThread__start__ + 1346 15 libsystem_pthread.dylib 0x075cfa26 _pthread_body + 138 16 libsystem_pthread.dylib 0x075cf99c _pthread_start + 155 17 libsystem_pthread.dylib 0x075ccf96 thread_start + 34 Thread 19 crashed with X86 Thread State (32-bit): eax: 0x00000000 ebx: 0x7c326800 ecx: 0x00000002 edx: 0x147ac858 edi: 0x040b73b8 esi: 0x7c39ee00 ebp: 0xb0830b48 esp: 0xb0830b20 ss: 0x00000023 efl: 0x00010206 eip: 0x040b741f cs: 0x0000001b ds: 0x00000023 es: 0x00000023 fs: 0x00000023 gs: 0x0000000f cr2: 0x00000028 Logical CPU: 2 Error Code: 0x00000004 Trap Number: 14 不是scrollTo中的选项...您可以尝试

.animate()

或者您可以阅读scrollTo() here